The terms for the two architectural designs for Java Web Applications first appeared in the early drafts of the JSP specifications: Model 1 and Model 2.
Input Processing Output
1.Model 1 architecture: Page-centric
In this architecture, the application is page-centric. The client browser navigates through a series of JSP pages in which any JSP page can employ a JavaBean that performs business operations. However, the highlight of this architecture is that each JSP page processes its own input. Applications implementing this architecture normally have a series of JSP pages where the user is expected to proceed from the first page to the next. If needed, a servlet or an HTML page can be substituted for the JSP page in the series. The advantage of this model is that it is easy to be implemented but the main drawback is that it does not provide work separation for the web designer and for the coder, and along with this, the structure is not flexible for changes when the project gets larger.
Fig 11. Page-centric architecture: Model 1
2. Model 2 architecture: MVC
The MVC paradigm is a way of dividing an application in three parts: the model, the view, and the controller. MVC was originally developed to map the traditional input, processing, output roles into the GUI. The similarity is the following:
Controller Model View
Model-view-controller (MVC) is in fact a software architecture (some calls it design pattern) that separates an application\'s data model, user interface, and control logic into three distinct components so that modifications to one component can be made with minimal impact to the others.
The function of the Model Component manages the behavior and data of the application domain, responds to requests for information about its state (usually from the view), and responds to instructions to change state (usually from the controller). Another explanation upon the Model concept is that it represents the domain-specific representation of the information on which the application operates. All the business logic is implemented in the Model. Data entered by the user through View are check in the model before saving into the database for example. Data access, Data validation and the data saving logic are also part of Model. To gather the functionality of the model, the followings must be noted:
o Encapsulate application state
o Responds to state queries
o Exposes application functionality
o Notifies view if any change occurs
The function of the View Component is that it renders the model into a form suitable for interaction, typically a user interface element. MVC is often seen in web applications, where the view is the HTML page and the code which gathers dynamic data for the page. To gather the functionality of the model, the followings must be noted:
o Renders the models
o Requests updates from model
o Sends user gesture to controller
o Allows controller to select view
The function of the Controller component is to respond to events (user actions-interprets the input) and invokes changes on the model and view. It translates practically interactions from the view into actions to be performed by the model. In a Web-application, user interaction appears as HTTP requests. The actions performed by the model include activating business processes or changing the state of the model. Based on the user interactions and the outcome of the model actions, the controller responds by selecting an appropriate view. To gather the functionality of the model, the followings must be noted:
o Defines application behavior
o Maps user actions to model updates
o Selects view for response
Fig 12 The MVC architecture
An example of such configuration is: JSP as view, Servlet as controller and EJB components for model. The main benefit for applying the Model-View-Controller (MVC) architecture to a JavaTM 2 Platform, Enterprise Edition (J2EETM) application, there can be separated core business model functionality from the presentation and control logic that uses this functionality. Such a separation allows multiple views to share the same enterprise data model, which makes supporting multiple clients easier to implement, test, and maintain. The force of this Model 2 Architecture stand thus in supporting multiple types of views where the interactions should not impact the components that provides the core functionality of the enterprise application
3.2.2 Struts framework
Struts Frame work is the implementation of Model-View-Controller (MVC) design pattern for the JSP from the Apache Jakarta project. Struts Framework is suited for the application of any size and is maintained as open-source.
The objective of the Apache Struts project is to emphasize application architectures based on the Model 2 approach, based on the Model-View-Controller (MVC) design paradigm or concept.