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

Computer Notes

Library
    • Computer Fundamental
    • Computer Memory
    • DBMS Tutorial
    • Operating System
    • Computer Networking
    • C Programming
    • C++ Programming
    • Java Programming
    • C# Programming
    • SQL Tutorial
    • Management Tutorial
    • Computer Graphics
    • Compiler Design
    • Style Sheet
    • JavaScript Tutorial
    • Html Tutorial
    • Wordpress Tutorial
    • Python Tutorial
    • PHP Tutorial
    • JSP Tutorial
    • AngularJS Tutorial
    • Data Structures
    • E Commerce Tutorial
    • Visual Basic
    • Structs2 Tutorial
    • Digital Electronics
    • Internet Terms
    • Servlet Tutorial
    • Software Engineering
    • Interviews Questions
    • Basic Terms
    • Troubleshooting
Menu

Header Right

Home » Struts2 » Struts2 Vs Struts1
Next →
← Prev

Struts2 Vs Struts1

By Dinesh Thakur

Both versions of Struts hosting framework provide the following three key components:
• A request handler provided by the application developer that maps Java classes to standard URI.
• A response handler that maps control to server pages or other Web resources which then will be responsible for completing the response.
• A tag library that helps developers to creating rich, responsive, form-based applications with server pages.

We’ll be covering the following topics in this tutorial:

  • Difference between Struts1 and Struts2
  • 1. ACTION CLASS
  • 2. Threading Model
  • 3. Servlet Dependency
  • 4. Expression Language
  • 5. Binding Values into Views
  • 6. Crosscutting for Action Form
  • 7. Control of Action Execution
  • 8. Type Conversion

Difference between Struts1 and Struts2

1. ACTION CLASS

In Struts 1 Action classes extend an abstract base class. A common problem in Struts 1 is use abstract classes instead of interfaces.

In Struts 2 Action class may implement an Action interface, with other interfaces to enable require services. Struts 2 provides a base ActionSuppport class to implement commonly used interfaces. The Action interface is not required. Any POJO object with a execute can be used as an Struts 2 Action object.

      ACTION CLASS

2. Threading Model

Struts1 Actions are singletons and must be thread- safe since there will only be one instance of a class to handle all requests for that Action. The singleton strategy places restrictions on what can be done with Struts 1 Actions and requires extra care to develop. Action resources must be thread-safe or synchronized.

Struts2 Action objects are instantiated for each request, so there are no thread-safety issues. (In practice, servlet containers generate many throw away objects per request, and one more object does not impose a performance penalty or impact garbage collection.)

      Threading Model

3. Servlet Dependency

In Struts1 the HttpServletRequest and HttpServlet Response is passed to the execute method when an Action is invoked as the as Actions have dependencies on the servlet API.

Struts2 Actions are not coupled to a container. Struts2 Actions can access the original request and response, if required. However, other architectural elements reduce or eliminate the need to access the HttpServetRequest or HttpServlet Response directly.

      Servlet Dependency

4. Expression Language

Struts1 integrates several tag libraries, so it uses the JSTL EL. The EL has basic object graph traversal, but relatively weak collection and indexed property support Tag libraries for JSP.

Struts2 can use JSTL single tag library that covers all, but the framework also supports a more powerful and flexible expression language called “Object Graph Notation Language” (OGNL) data transfer /type conversion.

      Expression Language

5. Binding Values into Views

Struts1 uses the standard JSP mechanism for binding objects into the page context for access.

Struts2 uses a “ValueStack” technology so that the taglibs can access values without coupling. The ValueStack technique allows reuse of views across a range of types which may have the same property name but different property types.

      Binding Values into Views

6. Crosscutting for Action Form

Struts1 uses an ActionForm object to handle the input like Actions, HTML form is mapped to an ActionForm instance, all ActionForms must extend a base class. Since other JavaBeans cannot be used as ActionForms, developers often create redundant classes to handle input.

Struts2 uses Action properties as input properties, eliminating the need for a second input object. Input properties may be rich object types which may have their own properties. The Action properties can be accessed from the web page via the taglibs. Struts2 also support the ActionForm pattern, as well as POJO form objects and POJO Actions. HTML form maps directly to a POJO. Rich object types, including business or domain objects, can be used as input/output objects.

      Crosscutting for Action Form

7. Control of Action Execution

Struts1 supports separate Request Processors or each module, but all the Actions in the module must share the same lifecycle.

Struts2 supports creating different lifecycles as per Action basis via Interceptor Stacks. Custom stacks can be created and used with different Actions, as needed.

      Control of Action Execution

8. Type Conversion

Struts1 Action Form properties are usually all Strings. Struts1 use Commons-Beanutils for type conversion. Converters are per-class, and not configurable per instance.

Struts2 use OGNL for type conversion. The framework includes converters for basic and common object types and primitives.

Next →
← Prev
Like/Subscribe us for latest updates     

About Dinesh Thakur
Dinesh ThakurDinesh Thakur holds an B.C.A, MCDBA, MCSD certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps.

Dinesh Thakur is a Freelance Writer who helps different clients from all over the globe. Dinesh has written over 500+ blogs, 30+ eBooks, and 10000+ Posts for all types of clients.


For any type of query or something that you think is missing, please feel free to Contact us.


Primary Sidebar

Structs Tutorials

Structs Tutorials

  • Struts - MVC Architecture
  • Struts - Framework Architecture
  • Struts - Struts2 Vs Struts1
  • Struts - Examples
  • Struts - Actions
  • Struts - Overview
  • Struts - Framework

Other Links

  • Structs - PDF Version

Footer

Basic Course

  • Computer Fundamental
  • Computer Networking
  • Operating System
  • Database System
  • Computer Graphics
  • Management System
  • Software Engineering
  • Digital Electronics
  • Electronic Commerce
  • Compiler Design
  • Troubleshooting

Programming

  • Java Programming
  • Structured Query (SQL)
  • C Programming
  • C++ Programming
  • Visual Basic
  • Data Structures
  • Struts 2
  • Java Servlet
  • C# Programming
  • Basic Terms
  • Interviews

World Wide Web

  • Internet
  • Java Script
  • HTML Language
  • Cascading Style Sheet
  • Java Server Pages
  • Wordpress
  • PHP
  • Python Tutorial
  • AngularJS
  • Troubleshooting

 About Us |  Contact Us |  FAQ

Dinesh Thakur is a Technology Columinist and founder of Computer Notes.

Copyright © 2025. All Rights Reserved.

APPLY FOR ONLINE JOB IN BIGGEST CRYPTO COMPANIES
APPLY NOW