• Skip to main content
  • Skip to secondary menu
  • Skip to primary sidebar

JavaTutorOnline

Java Tutor Online

  • Home
  • Courses
  • Tutorials
    • Java
    • Servlets
    • Struts
    • Spring
    • Webservice
  • FAQ
  • Testimonials
  • Blog
  • Contact Us

Struts 1 and Struts 2 Difference

This tutorial lists the difference between struts 1 and struts 2.

struts1_vs_struts2_difference

1. Front Controller

strut 1.x– Front controller used is a servlet called the ActionServlet

struts 2.x– A Filter called FilterDispatcher is used a the front controller.

You may check the article How Struts 2 Works to have a good understanding of the working of struts 2.


2. ActionForms

strut 1.x– 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.

struts 2.x– Acton Forms are not used. The jsp form directly maps to POJO classes, and there is no need to create DTO, thereby the number of classes decreases leading to less maintenance.


3. Validation

strut 1.x– Validation can be done in validate method of the Form Bean.

struts 2.x– No Form Beans so validation code can be put in the Action classes or validator framework can be used.


4. Expression Language

strut 1.x– Jstl(Java Standard Tag Library) is used for expression language.

struts 2.x– Also uses OGNL (Object Graphic Notation Language) as expression language and it is stronger then JSTL. But struts 2.x can also use JSTL.


5. Configuration File

strut 1.x– The configuration file used is struts-config.xml, it may be “anyname.xml” and is put in side web-inf folder.

struts 2.x-The name of the configuration file is struts.xml and is placed inside web-inf/classes folder. Multiple configuration files can also be used.


6. Action Classes

strut 1.x– Action classes have to extend base abstract class, there by cannot extend any other classes.

struts 2.x– Action classes are more flexible and can be created by implementing Action interface, extending ActionSupport class or by a POJO class just having execute() method.


7. Thread Safety

strut 1.x– Action Classes were singleton and not thread safe. Only one instance of a class is used to handle all requests to an Action.

struts 2.x– Action objects are instantiated for every request, so there are no thread-safety issues.


8. Type Conversion

strut 1.x– Properties in ActionForm are generally Strings. Commons-Beanutils is used i struts 1 for type conversion.

struts 2.x– OGNL is used for type conversion. Struts 2 includes converters for common object types and primitive data types.


9. Servlet Dependency

strut 1.x– Action classes execute method has parameters of type HttpServletRequest and HttpServletResponse. So struts 1.x actions has a dependency on servlet api.

struts 2.x–  Action class in struts 2 don’t have servlet dependency, because its execute() method doesn’t accept any parameters. But if required Struts 2 Actions can still access the request and response.


10. View

strut 1.x– Generally JSP pages are used for views.

struts 2.x– There is support for multiple view technologies like velocity, Freemarker, jasper reports, jsp etc.

Filed Under: Struts

Reader Interactions

Comments

  1. nita says

    April 10, 2019 at 5:57 am

    Nice explanation!!!

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Mr Chinmay

Chinmay Patel
Online Java Tutor-Demo Class

Phone & Whatsapp +919853166385
[email protected]

Recent Posts

  • How to Learn Java in One day? | JavaTutorOnline
  • Constructor in Java and Overloaded Constructor Example Program
  • Important Interview Questions on Java Multithreading
  • React Spring Boot Web Services Integration
  • Spring Boot RESTful Web Services Example
  • Top Spring MVC Interview Questions and Answers for Developers
  • Top Spring Core Interview Questions and Answers for Developers
  • Host Java Web Apps for Free on Mobile with Tomcat and Termux
  • How to Deploy Java Web Application on Aws EC2 with Elastic IP
  • Simple Jsp Servlet Jdbc User Registration using Tomcat Mysql and Eclipse
Copyright © 2025 JavaTutorOnline