The web.xml File (Deployment Descriptor)
This is the file which the container reads. This file has all the configuration information which we have defined for our web application. The configuration information includes the index file, the default welcome page, the mapping of our servlets including path and the extension name, any init parameters, information related to the context elements.
In the file WEB-INF/web.xml of struts application we need to configure the Struts ActionServlet which handles all the request made by the web browsers to a given mapping.
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. ActionServlet is the central component of the Struts controller. This servlet extends the HttpServlet. This servlet basically performs two important things.
- When the container gets start, it reads the Struts Configuration files and loads it into memory in the init() method. You will know more about the Struts Configuration files below.
- It intercepts the HTTP request in the doGet() and doPost() method and handles it appropriately.
The struts-config.xml File
- This file contains all of the routing and configuration information for the Struts application.
- The name of this file can be changed. The name of the struts configuration file can be configured in the web.xml file.
- This file is placed under the WEB-INF directory of the web application.
- This file is used to associate paths with the controller components of your application., known as Action classes like <action path =”/login” type = “LoginAction”>. This tag tells the Struts ActionServlet that whenever the incoming request is http://myhost/myapp/login.do, then it must invoke the controller component LoginAction. Above, you can see that we have written .do in the URL. This mapping is done to tell the web application that whenever a request is received with the .do extension then it should be appended to the URL.
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.
View Resources
View resources consist of Java Server Pages, HTML pages, JavaScript and Stylesheet files, Resource bundles, JavaBeans, and Struts JSP tags.
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:
JavaBeans
EJB
CORBA
JDO
any other
source : Struts Tutorial