Results 1 to 7 of 7

Thread: Struts 1 VS Struts 2

  1. #1
    Join Date
    Sep 2010
    Posts
    71

    Struts 1 VS Struts 2

    I have just took an admission in software course where I am going to learn about the java and struts. I was just searching about the struts on an internet just to gain some knowledge about when I came to know that there are 2 struts. Now I don't which I an going to learn. By the way, Can somebody tell me what is the difference between these two?

  2. #2
    Join Date
    May 2009
    Posts
    511

    Re: Struts 1 VS Struts 2

    Competition between J2EE frameworks is high and only the adoption by a larger number helps preserve them. Struts 2 comes with the ambition to replace Struts 1 is now the reference framework for most developments. Despite the name, which can be confusing, Struts 2 is not a simple evolution of Struts 1. It originates from two J2EE framework, Struts 1 and WebWork.

  3. #3
    Join Date
    May 2009
    Posts
    637

    Re: Struts 1 VS Struts 2

    Given this fact, in December 2005, teams of Struts 1 and WebWork have pooled their expertise to develop a new framework called WebWork2, later renamed Struts 2, the first stable version was released February 22, 2007, under label 2.0.6. For its part, Struts 1 will continue to evolve and is now in its eighth official release (1.3.8) since March 10, 2007.
    • The WebWork project, initiated by the OpenSymphony company, began in March 2002. Created from the core Struts, the framework has evolved introducing new concepts and features, without the worry of compatibility with Struts. Contrary to expectations, this alternative to Struts has not met with a very strong attraction in the J2EE community.
    • Struts 1 framework is a solid, well tested by time and praised by many. As a result, the brakes backward compatibility in its evolution. Many critics have accumulated and can not be solved in the present state of things.

  4. #4
    Join Date
    May 2009
    Posts
    543

    Re: Struts 1 VS Struts 2

    The general architecture has not changed. However, the "ActionForm" a fundamental concept in Struts 1, Struts 2 have disappeared and are found directly integrated into the action classes. To emphasize the simplicity, the obligatory stop at the call for action by the method "execute" is more systematic. In fact, Struts 2 allows the call to action from any method implemented in the action. Struts 1 provides an abstract class "Action" and requires that all action classes extend it. Struts 2 provides a solution to this very notion criticized by providing an interface action. Thus, the action classes are free to inherit according to project needs another class while implementing the action interface of Struts 2.

  5. #5
    Join Date
    Apr 2009
    Posts
    488

    Re: Struts 1 VS Struts 2

    Within the life cycle of Struts 2 interceptors or interceptor batteries can be configured. They are used to perform pre / post processing on the request. Here is an example of interceptor used to verify the validity of the authentication of a user:
    Code:
    public class AuthenticationInterceptor implements Interceptor { 
      public String intercept(ActionInvocation actionInvocation){
       if (isAuthenticated(user))
       return actionInvocation.invoke(); //Authentication OK
       else
       return Action.LOGIN; //Redirection sur la page de login
       } 
    
    }
    The interceptor is defined in the configuration file and is applied within the same file on each action:
    Code:
    <interceptors> 
      <interceptor name="authentication"
                 class="project.interceptors.AuthenticationInterceptor"/> 
    
    </interceptors> 
    
    <action name="menu" class="project.actions.MenuAction"> 
      <interceptor-ref name=" authentication"/>
       <result>menu.jsp</result>
       <result name="input">form.jsp</result> 
    
    </action>

  6. #6
    Join Date
    May 2009
    Posts
    527

    Re: Struts 1 VS Struts 2

    Struts 2 uses the library xWork 2 to perform a type conversion and validation between the template and the action classes. Thus, all errors of conventional conversions (String -> Long / Integer / Float / Boolean ...) are automatically handled by this library. In addition, specific types of conversions can be created by implementing the abstract class "StrutsTypeConverter," facilitating the settlement of a bean from a form. To emphasize the simplicity, xWork 2 provides an interface "ModelDriven" that can be implemented by action in providing the type of object to map. The supplied object is directly accessible in the view using the language OGNL (Object Graph Navigation Language). A concrete example of a form to register a person:

    Definition of the subject Person:
    Code:
    public class Personne { 
      private String nom;
      private String prenom;
      //getters/setters
     ... 
    
    }
    Definition of action:
    Code:
    public class PersonneAction extends ActionSupport implements ModelDriven<Personne> { 
      public String execute(){
      return SUCCESS;
      } 
    
    }
    Definition of the JSP:
    Code:
     <%@ page contentType="text/html; charset=UTF-8"%>
    <%@ taglib prefix="s" uri="/struts-tags"%>
    <s:textfield name="model.nom" label="nom" />
    <s:textfield name="model.prenom" label="prenom" />
    <s:submit key="button.submit" value="Enregistrer" />
    Within the JSP, the attributes of the object "person" are directly passed as parameters through the model. With the OGNL language, "model.nom" represents both the getter and setter of the attribute name. In this way, the step of populating the object is achieved seamlessly without having to go through an "ActionForm" dear to Struts 1.

  7. #7
    jennyjohnson Guest

    Re: Struts 1 VS Struts 2

    Struts 1 requires action classes to increase abstract base class. Struts 2 provides a base Action. It support class to implement interfaces. Struts 1 uses an ActionForm object to capture input. Struts 2 uses Action properties as input.

Similar Threads

  1. Beginning with the Struts 2
    By Ronchi in forum Software Development
    Replies: 4
    Last Post: 19-03-2011, 06:02 AM
  2. JSF versus Struts
    By Daksha in forum Software Development
    Replies: 3
    Last Post: 21-07-2010, 05:50 AM
  3. How to mix Eclipse, WTP, Struts, and Hibernate
    By Efigenio in forum Software Development
    Replies: 5
    Last Post: 21-02-2010, 05:04 AM
  4. How to upgrade one of struts in JDEV 10.1.3
    By GeforceUser in forum Software Development
    Replies: 3
    Last Post: 14-11-2009, 05:15 PM
  5. Struts Forward Action with example
    By Visala28 in forum Software Development
    Replies: 2
    Last Post: 10-08-2009, 04:44 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,638,035,337.91403 seconds with 17 queries