DESIGN OF A WEB APPLICATION & WEB APP DEVELOPMENT” In the last session, you partially implemented a Web Model View Controller (MVC) design by separating out the model into JavaBeans and the view into JSPs.
This partial implementation of the MVC pattern provides significant advantages: independent development, better cohesion, and easier maintainability. For a full MVC architecture, though, you need to know how to separate out the controller elements as well.
The Classical 2 Building was accessible by Sun Microsystems in the early forms of the servlet specification. It is now a popularly used and discussed Model View Controller architecture for Java Web applications. The Model 2 Architecture is an MVC architecture that will separate out the controller elements.
MODEL 2 ARCHITECTURE:-
This architecture is shown in the UML The component diagram in Figure 29-1 and the UML Sequence diagram in Figure 29-2. Model 2 The architecture separates the model (JavaBeans) and the view (JSPs) just as you did in the last session. In addition, it has a single servlet used as the controller. All HTTP requests for any part of the Web application will be directed to this controller servlet.
The servlet will verify the input data from the HTTP request and call methods on the JavaBeans to update the data model. The servlet controller will then forward the request on to a JSP that will render the view. The JSP will access the JavaBeans to get the data that should appear on the Web page.
THE CONTROLLER SERVLET OF THE MODEL2:-
Architecture offers some additional benefits beyond the high cohesion and good maintainability of MVC. Because all requests for the Web application come through one servlet,
The developer can place generic security checks and audit logging code in the servlet and that code will be run for any request for any part of the Web application. In the discussion of the case study in Session 28, the two JSP views were separated from the model.
For a full Model 2 Architecture, the development team now adds a single servlet that will receive all requests that are sent by the Web browser for any part of the Web application. In this case,
The development team decides that having separate controllers for the wired Web clients and wireless Web clients could enhance maintainability. Thus, they use two servlet controllers instead of the usual one. Their new architecture is shown in Figure 29-3.