Struts 2 Vs Struts 1
Struts2 is much different than Struts1. Struts2 is more powerful and overcome all drawbacks of Struts1. But learning curve for experienced Struts1 developers are same as newbies. In fact, Struts2 is merged version of WebWork, which intended to overcome all Struts1 drawback.
Action Class :
In Struts2 action class implements an Action interface, but in Struts1 it was extends an Action class. This is a major difference and Struts2 action classes are POJO(Plain Old Java Object) hence testing is easy, no need to write HTTP mock objects to test action classes.
Thread Modeling :
Struts1 action classes are singleton, one instance per container, all request were handled by this one instance. ThreadSafe mechanism has to take care while developing Struts1 action class. In Struts2, action classes are not singleton, as many instance can created and there is no performance penalty and garbage collection overhead.
Servlet Dependency :
Sturts2 action classes are not servlet API dependent, because HTTPServletResponse and HTTPServletRequest objects will not be passed to execute methods directly.
ActionForm Input :
Struts1 action forms are extended from action form base class and action form inputs can't access by other JavaBeans. But in Struts2, action form inputs can be accessed from taglibs.
ValueStacks :
Struts1 uses standard JSP mechanism to bind objects into page views. But Struts2 uses valuestack technology to bind objects into page, hence taglibs can directly access objects without coupling page view (needed more understanding).
Control of Action Execution :
Struts1 supports separate request processor for each module, all are sharing same life cycle. Struts 2 supports creating different life cycles on a per Action basis via Interceptor Stacks.
Action Class :
In Struts2 action class implements an Action interface, but in Struts1 it was extends an Action class. This is a major difference and Struts2 action classes are POJO(Plain Old Java Object) hence testing is easy, no need to write HTTP mock objects to test action classes.
Thread Modeling :
Struts1 action classes are singleton, one instance per container, all request were handled by this one instance. ThreadSafe mechanism has to take care while developing Struts1 action class. In Struts2, action classes are not singleton, as many instance can created and there is no performance penalty and garbage collection overhead.
Servlet Dependency :
Sturts2 action classes are not servlet API dependent, because HTTPServletResponse and HTTPServletRequest objects will not be passed to execute methods directly.
ActionForm Input :
Struts1 action forms are extended from action form base class and action form inputs can't access by other JavaBeans. But in Struts2, action form inputs can be accessed from taglibs.
ValueStacks :
Struts1 uses standard JSP mechanism to bind objects into page views. But Struts2 uses valuestack technology to bind objects into page, hence taglibs can directly access objects without coupling page view (needed more understanding).
Control of Action Execution :
Struts1 supports separate request processor for each module, all are sharing same life cycle. Struts 2 supports creating different life cycles on a per Action basis via Interceptor Stacks.
The following are additions of Struts2
- instant support of AJAX,
- integration with Spring dependency injection,
- Configuration based profiling
- Debugging
Source :
http://struts.apache.org/2.0.11.1/index.html
Comments