Saturday, November 20, 2010

Differences Between Struts 1 and Struts 2

Base Action class is  abstract class in Struts1 where as it is Interface in Struts2 and
also provides a base ActionSupport class that implements commonly used interfaces.

Struts 1 Actions are singletons and must be thread-safe where as
Struts 2 doesn't have thread-safety issues as Action objects are instantiated for each request.

Actions are dependent on the servlet API , as HttpServletRequest and HttpServletResponse are passed to execute method in Struts1 but in case of Struts 2, Actions are not container dependent because they are made simple POJOs. In struts 2, the servlet contexts are represented as simple Maps.

Testing Struts2 action is simple as there is no Servlet API usage in execute method .

Struts 1 recieves an input by creating an ActionForm object which extend a ActionForm base class.
            Other JavaBeans classes cannot be used.
Struts 2 requires Action properties as input properties ,these Input properties may be rich object types.

Struts 1 integrates with JSTL, so it uses the JSTL EL(Expression Language http://en.wikipedia.org/wiki/Expression_Language).
Struts 2 can use JSTL, but the framework also supports a more powerful language called "Object Graph Notation Language" (OGNL).

Struts 1 binds objects into the page context by using the standard JSP mechanism.
Struts 2 uses a ValueStack technology to make the values accessible to the taglibs
             without coupling the view to the object to which it is rendering.

Struts 1 ActionForm properties are almost in the form of Strings. Commons-Beanutils are
            used by used by Struts 1 for type conversion.
Struts 2 uses OGNL for type conversion.

Struts 1 uses manual validation that is done via a validate method on the ActionForm, or
            by using an extension to the Commons Validator.
Struts 2 allows manual validation that is done by using the validate method and the XWork Validation framework.

Each module in Struts 1 has a separate Request Processors (lifecycles), while all the Actions in the module must share the same lifecycle.
In Struts 2 different lifecycles are created on a per Action basis via Interceptor Stacks.

For Full comparision Between Struts 1 and Struts 2
http://struts.apache.org/2.0.14/docs/comparing-struts-1-and-2.html

Tags
Struts,Differences,Frame Works,

No comments: