Use MVC (Model View Controller) to separate the representation of information from the user’s interaction with it.

The Model-View-Controller paradigm applied to web applications lets you separately display code (for example, HTML and tag libraries that is rendered to the end users) from flow control logic (action classes that performs the required operations on the data) from the data model (data persisting inside the relational databases) to be displayed and updated by the application.



The basic idea of the MVC architecture is to divide the application into three layers: Model that represents the data layer, a view layer that represents the data processed by the model component; and a Controller component that is responsible for interaction between the model and the controller.


In the context of web application developed in java when implemented with MVC architecture is aggregated as the struts framework. Many versions of struts have been released till now. The latest version of struts is 2.3.x. Struts framework is the open source framework from the Apache Software Foundation.



Struts Components :



1. The Controller :
This receives all incoming requests. Its primary function is the mapping of a request URI to an action class selecting the proper application module. It’s provided by the framework.



2. The struts-config.xml File:
This file contains all of the routing and configuration information for the Struts application. This XML file needs to be in the WEB-INF directory of the application.

3. Action Classes:
It’s the developer’s responsibility to create these classes. They act as bridges between user-invoked URIs and business services. Actions process a request and return an ActionForward object that identifies the next component to invoke. They’re part of the Controller layer, not the Model layer.

4. View Resources:
View resources consist of Java Server Pages, HTML pages, JavaScript and Style sheet files, Resource bundles, JavaBeans, and Struts JSP tags.



5. ActionForms:
These greatly simplify user form validation by capturing user data from the HTTP request. They act as a “firewall” between forms (Web pages) and the application (actions). These components allow the validation of user input before proceeding to an Action. If the input is invalid, a page with an error can be displayed.



Model Components:


The Struts Framework has no built-in support for the Model layer. Struts supports any model components:
1. JavaBeans
2. EJB