Struts 1 vs Struts 2 (I)
16 January 2008In the following article, we are going to compare the various features between the two frameworks. Struts 2 is very simple as compared to struts 1, few of its important features are:
1. Servlet Dependency
Actions in Struts1 have dependencies on the servlet API since the HttpServletRequest and HttpServletResponse objects are passed to the execute method when an Action is invoked while in case of Struts 2, Actions are not container dependent because they are made of simple POJOs.
In Struts 2, the servlet contexts are represented as simple Maps which allows actions to be tested in isolation. Struts 2 Actions can access the original request and response, if required. However, other architectural elements reduce or eliminate the need to access the HttpServetRequest or HttpServletResponse directly.
2. Action classes
Programming the abstract classes instead of interfaces is one of major design issues of struts1 framework that has been resolved in the struts 2 framework.
Struts1 Action classes needs to extend framework dependent abstract base class, while in case of Struts 2 Action class may or may not implement interfaces to enable optional and custom services. In case of Struts 2 , Actions are not container dependent because they are made simple POJOs.
Struts 2 provides a base ActionSupport class to implement commonly used interfaces. Perhaps, the Action interface is not required. Any POJO object with an execute signature can be used as an Struts 2 Action object.
3. Validation
Struts1 and Struts 2 both supports the manual validation via a validate method.
Struts1 uses validate method on the ActionForm, or validates through an extension to the Commons Validator. However, Struts 2 supports manual validation via the validate method and the XWork Validation framework. The Xwork Validation Framework supports chaining validation into sub-properties using the validations defined for the properties class type and the validation context.
Related Posts:
Top Of Page | Trackback
If you found this page useful, consider linking to it. Simply copy and paste the code below into your web site.
It will look like this: Struts 1 vs Struts 2 (I)