Web Development in J2EE Using the MVC Design Pattern
Web services application development is a huge topic covering a broad range of technologies and topics. In this article we will discuss Web services development in J2EE and examine the Model/View/Controller design pattern, thereby explaining how it separates business logic implementation and persistence from presentation. We shall briefly introduce the Struts Framework, one that facilitates web services development within the IBM WebSphere Studio Application Developer edition. (This article was originally published in the June 2004 issue of Plug-In).
Web Development in J2EE Using the MVC Design Pattern - Examining Servlets and Java Server Pages (Page 2 of 5 )
The process described above occurs in a Java J2EE environment by using Java Servlets for processing client requests and delegating the requested task(s) to a Java Bean or an Enterprise JavaBean (EJB) for data persistence or retrieval. Subsequently, the Servlet utilizes a Java Server Page (JSP) to return the response or results to the client. J2EE specifications provide support for Web development and offer numerous alternatives for creating Web applications. Java Servlets have become increasingly popular in recent years and interact seamlessly with JSPs. Servlets offer the advantage of being written in Java, implementing presentation logic and managing Web browser client requests.
Additionally, they create a single heavyweight process and facilitate user requests by using a lightweight thread maintained by the Java Virtual Machine. A servlet is designed to map to one or more URLs. When the server receives a specified servlet’s URL request, the service() method is invoked and subsequently responds. Each request is associated with an individual client call. This allows multiple users to invoke the service method simultaneously, a major benefit for users.
Unfortunately, servlets also have a negative side. HTML is hard coded, making modifications to a servlet difficult because for every change, a servlet recompile is necessary. Also, determining a user’s locale, language, and other variants is difficult to accomplish in HTML. In fact, internationalization issues are frequently bypassed in Web development because a unique servlet is required for each individual locale. This is altogether too cumbersome. There must be another answer.