Saturday, November 20, 2010

What is Struts ?

What is Struts ?
Apache Struts is a free open-source framework for creating Java web applications.

Difference Between Struts 1 and Struts 2


Struts1 was an action- oriented framework that implemented a Model-View-Controller (MVC) separation of concerns in its architecture.
Struts2 is a brand new implementation of those same MVC principles in an action-oriented framework.

Difference Between Struts 1 and Struts 2.

Why we need MVC framework?

Why we need Struts ?

  To Bind request parameters to Java types
  To Validate data
  To Make calls to business logic
  To Make calls to the data layer
  To Render presentation layer (HTML, and so on)
  To Provide internationalization and localization                                    
 
STRUTS2 FEATURES: 


  Interceptors for layering cross-cutting concerns away from action logic;
  Annotation-based configuration to reduce or eliminate XML configuration;
  Powerful expression language, Object-Graph Navigation Language(OGNL), that transverses the entire framework.
  Mini-MVC–based tag API that supports modifiable and reusable UI components.
  The framework's architecture and tags are buzzword compliant.
  Struts works well with conventional REST applications and with nouveau technologies like SOAP and AJAX.


Resources for Understanding and Using Struts

Sturts developers guide Link http://struts.apache.org/2.x/docs/core-developers-guide.html

Struts examples http://struts.apache.org/2.x/docs/strutsxml-examples.html


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,