Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 3

Struts1 Vs Struts2

Struts 2 While in Struts 2, an Action class implements an Action interface, along with other interfaces use Struts1 extends the abstract base optional and custom services. Struts class by its action class. The 2 provides a base ActionSupport Action classes problem with struts1 is that it class that implements commonly uses the abstract classes rather used interfaces. Although an Action than interfaces. interface 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-safeStruts 2 doesn't have thread-safety because only one instance of a issues as Action objects are class handles all the requests for instantiated for each request. A that Action. The singleton servlet container generates many Threading Model strategy restricts to Struts 1 throw-away objects per request, and Actions and requires extra care to one more object does not impose a make the action resources thread performance penalty or impact safe or synchronized while garbage collection. developing an application. Container does not treat the Struts 2 Actions as a couple. Servlet Actions are dependent on the contexts are typically represented as servlet API because simple Maps that allow Actions to HttpServletRequest and be tested in isolation. Struts 2 Servlet HttpServletResponse is passed to Actions can still access the original Dependency the execute method when an request and response, if required. Action is invoked therefore While other architectural elements Struts1. directly reduce or eliminate the need to access the HttpServetRequest or HttpServletResponse. Struts1 application has a major To test the Struts 2 Actions problem while testing the instantiate the Action, set the application because the execute Testability properties, and invoking methods. method exposes the Servlet API. Dependency Injection also makes Struts TestCase provides a set of testing easier. mock object for Struts 1. Struts 1 recieves an input by creating an ActionForm object. Struts 2 requires Action properties as input properties that eliminates Like the action classes, all ActionForms class must extend a the need of a second input object. These Input properties may be rich ActionForm base class. Other JavaBeans classes cannot be used object types, since they may have Harvesting Input as ActionForms, while their own properties. Developer can access the Action properties from developers create redundant the web page using the taglibs. classes to receive the input. Struts 2 also supports the DynaBeans is the best alternative ActionForm pattern, POJO form to create the conventional objects and POJO Actions as well. ActionForm classes. Struts1 integrates with JSTL, so it Struts 2 can use JSTL, but the uses the JSTL EL. The EL has framework also supports a more Expression basic object graph traversal, but powerful and flexible expression Language

Feature

Struts 1

You might also like