Struts is used to create a web applications based on servlet and JSP. Struts depend on the MVC (Model View Controller) framework. Struts application is a genuine web application. Struts are thoroughly useful in building J2EE (Java 2 Platform, Enterprise Edition) applications because struts takes advantage of J2EE design patterns. Struts follows these J2EE design patterns including MVC.
In struts, the composite view manages the layout of its sub-views and can implement a template, making persistent look and feel easier to achieve and customize across the entire application. A composite view is made up by using other reusable sub views such that a small change happens in a sub-view is automatically updated in every composite view.
Struts consists of a set of own custom tag libraries. Struts are based on MVC framework which is pattern oriented and includes JSP custom tag libraries. Struts also supports utility classes.
Features of Struts: Struts has the following features:
- Struts encourages good design practices and modeling because the framework is designed with “time-proven” design patterns.
- Struts is almost simple, so easy to learn and use.
- It supports many convenient features such as input validation and internationalization.
- It takes much of the complexity out as instead of building your own MVC framework, you can use struts.
- Struts is very well integrated with J2EE.
- Struts has large user community.
- It is flexible and extensible, it is easy for the existing web applications to adapt the struts framework.
- Struts provide good tag libraries.
- It allows capturing input form data into javabean objects called Action forms.
- It also hand over standard error handling both programmatically and declaratively.
Working of Struts:
In the initialization phase, the controller rectify a configuration file and used it to deploy other control layer objects. Struts configuration is form by these objects combined together. The struts configuration defines among other things the action mappings for an application.
Struts controller servlet considers the action mappings and routes the HTTP requests to other components in the framework. Request is first delivered to an action and then to JSP. The mapping helps the controller to change HTTP requests into application actions. The action objects can handle the request from and responds to the client (generally a web browser). Action objects have access to the applications controller servlet and also access to the servlet’s methods. When delivering the control, an action objects can indirectly forward one or more share objects, including javabeans by establish them in the typical situation shared by java servlets.