Difference Between Struts 1 and Struts 2

1) ActionServlet is the Controller Servlet used in Struts 1. The same work is done by a Filter in Struts2.

2) ActonForms are used in Struts 1. These classes map with the jsp forms. The Action classes use the data in these ActonForms to populate Data Transfer Objects. But in Struts 2 Acton Forms are not used. The jsp forms direct map to POJO, and there is no need to create DTO, thereby the number of classes decreases leading to less maintenance.

3) Validation can be done in validate method of FormBean in Struts 1, but in Struts there is no FormBeans so validation code can be put in Action classes or Validator Framework can be used.

4) In Struts 1 the bean and logic tag libraries are often replaced by JSTL, but Struts 2 has such tag libraries that we don’t need to use JSTL.

5) Default location of the Single Configuration used in Struts 1 is the WEB-INF folder, whereas multiple configuration files can be used in struts 2 and should be put directly inside or sub directories in WEB-INF/classes.

6) Java 5 and servlet 2.4 are prerequisites for struts 2 because Annotation are heavily used in Struts 2.

7) In Struts 1 the action classes are made by subclassing the Action class but in struts 2 they are made by sub classing the ActionSupport class. An action class at the top can be used to service related actions.

Leave a Reply