Docstoc

struts1and struts2

Document Sample
struts1and struts2 Powered By Docstoc
					Feature               Struts 1                                      Struts 2
                                                                    While in Struts 2, an Action class implements
                                                                    an Action interface, along with other
                                                                    interfaces use optional and custom services.
                      Struts1 extends the abstract base class by
                                                                    Struts 2 provides a base ActionSupport class
                      its action class. The problem with struts1 is
Action classes                                                      that implements commonly used interfaces.
                      that it uses the abstract classes rather than
                                                                    Although an Action interface
                      interfaces.
                                                                    is not necessary, any POJO object along with
                                                                    an execute signature can be used as an Struts
                                                                    2 Action object.
                      Struts 1 Actions are singletons therefore
                      they must be thread-safe because only one Struts 2 doesn't have thread-safety issues as
                      instance of a class handles all the requests Action objects are instantiated for each
                      for that Action. The singleton strategy       request. A servlet container generates many
Threading Model
                      restricts to Struts 1 Actions and requires    throw-away objects per request, and one
                      extra care to make the action resources       more object does not impose a performance
                      thread safe or synchronized while             penalty or impact garbage collection.
                      developing an application.
                                                                    Container does not treat the Struts 2 Actions
                                                                    as a couple. Servlet contexts are typically
                      Actions are dependent on the servlet API represented as simple Maps that allow
                      because HttpServletRequest and                Actions to be tested in isolation. Struts 2
Servlet Dependency    HttpServletResponse is passed to the          Actions can still access the original request
                      execute method when an Action is invoked and response, if required. While other
                      therefore Struts1.                            architectural elements directly reduce or
                                                                    eliminate the need to access the
                                                                    HttpServetRequest or HttpServletResponse.
                      Struts1 application has a major problem
                                                                    To test the Struts 2 Actions instantiate the
                      while testing the application because the
                                                                    Action, set the properties, and invoking
Testability           execute method exposes the Servlet API.
                                                                    methods. Dependency Injection also makes
                      Struts TestCase provides a set of mock
                                                                    testing easier.
                      object for Struts 1.
                      Struts 1 recieves an input by creating an     Struts 2 requires Action properties as input
                      ActionForm object. Like the action classes, properties that eliminates the need of a
                      all ActionForms class must extend a           second input object. These Input properties
                      ActionForm base class. Other JavaBeans may be rich object types, since they may have
Harvesting Input      classes cannot be used as ActionForms,        their own properties. Developer can access
                      while developers create redundant classes the Action properties from the web page
                      to receive the input. DynaBeans is the best using the taglibs. Struts 2 also supports the
                      alternative to create the conventional        ActionForm pattern, POJO form objects and
                      ActionForm classes.                           POJO Actions as well.
                      Struts1 integrates with JSTL, so it uses the Struts 2 can use JSTL, but the framework
                      JSTL EL. The EL has basic object graph also supports a more powerful and flexible
Expression Language
                      traversal, but relatively weak collection and expression language called "Object Graph
                      indexed property support.                     Notation Language" (OGNL).
                                                                    Struts 2 uses a ValueStack technology to
                                                                    make the values accessible to the taglibs
                                                                    without coupling the view to the object to
Binding values into   Struts 1 binds objects into the page context
                                                                    which it is rendering. The ValueStack
views                 by using the standard JSP mechanism.
                                                                    strategy enables us to reuse views across a
                                                                    range of types, having same property name
                                                                    but different property types.
                      Struts 1 ActionForm properties are almost Struts 2 uses OGNL for type conversion and
Type Conversion
                      in the form of Strings. Commons-Beanutils converters to convert Basic and common
                    are used by used by Struts 1 for type        object types and primitives as well.
                    conversion. Converters are per-class, which
                    are not configurable per instance.
                    Struts 1 uses manual validation that is done Struts 2 allows manual validation that is done
                    via a validate method on the ActionForm, by using the validate method and the XWork
                    or by using an extension to the Commons Validation framework. The Xwork Validation
Validation          Validator. Classes can have different        Framework allows chaining of validations
                    validation contexts for the same class,      into sub-properties using the validations
                    while chaining to validations on sub-        defined for the properties class type and the
                    objects is not allowed.                      validation context.
                    Each module in Struts 1 has a separate       In Struts 2 different lifecycles are created on
Control Of Action   Request Processors (lifecycles), while all a per Action basis via Interceptor Stacks.
Execution           the Actions in the module must share the Custom stacks are created and used with
                    same lifecycle.                              different Actions, as

				
DOCUMENT INFO
Shared By:
Stats:
views:29
posted:7/27/2012
language:English
pages:2
Description: diffrence struts1and struts2