BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Migrating Applications to Struts2

Migrating Applications to Struts2

Bookmarks
Struts was first released in June of 2001. Since that time it has become the de-facto standard for web application development. Many other frameworks such as WebWork, RIFE, JSF, and Tapestry have risen in the years that have followed. None of them including Struts successors such as Shale and Struts Ti have been able to completely move developer attention away from Struts. In December 2002 it was announced that WebWork and Struts Ti would join forces to become Struts Action Framework 2.0 and the official successor to Struts.

In a new InfoQ article series, Ian Roughley looks at the task of moving applications from Struts to Struts2. The series seeks to introduce the concepts and new features available in Struts2 in order to arm developers with the knowledge needed to migrate their applications. The first article includes a walk through of the request life-cycle in Struts2, configuration, and the action differences between the old and new versions of the framework.

Read Converting to Struts2 - Part I

...Before we start the migration process, a little background to Struts2 is needed. The first part of this article will introduce Struts2, along with some of the core architectural differences that will help to conceptually put everything together. The second part will cover migrating the back-end - an in-depth look at the differences between actions; action related framework features; and action configuration. The final part of this article will address the user interface. We'll cover the architecture; talk about UI components, themes and tags; and put a new face on our application.

It is not my intent to cover every migration scenario available, but rather to introduce the concepts and new features available in Struts2 by starting from a common starting point. Armed with this knowledge, migrating an application of any size should be a piece of cake!...

Rate this Article

Adoption
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

  • One typo?

    by Wendong Li,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    December 2002 -> December 2005

  • I dont like the idea of Action helper interface

    by karan malhi,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    If you don't like the idea of string literals in your code, there is a helper interface Action available that provides the common results of "success", "none", "error", "input" and "login" as constants.


    If I dont like the idea of string literals, then I would create my own helper interface. In fact, I dont like the idea of getting a helper interface just for some constants, which I may not even use. This is a domain specific thing and its place is in a domain specific model , rather than a framework.

  • Re: One typo?

    by Ian Roughley,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    yes - you're right.

  • Re: I dont like the idea of Action helper interface

    by Ian Roughley,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    I tend to disagree, but this is your choice. I would never place the results for an action call in a domain object, it just doesn't belong there. It has nothing to do with the domain in question, but rather what happened during the processing of an action, and what is the next step in the flow of processing actions / views.

  • Re: One typo?

    by Ian Roughley,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Actually, I was wrong in my comment, and the article is correct. WebWork was forked in March 2002 and in December 2005 is was announced that Struts and WebWork would join forces.

  • Re: I dont like the idea of Action helper interface

    by karan malhi,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    What I meant was, that in my application, I may not have the notion of success or login etc. These terms are more application specific rather than framework specific. Just choosing a bunch of terms and adding them to the framework doesnt make sense to me. I think the choice of terminology and its interpretation is totally related to the domain/application in question

  • Re: I dont like the idea of Action helper interface

    by Pete the Wheat,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Shouldn't "org.apache.struts.action2.dispatcher.FilterDispatcher" be "org.apache.struts2.dispatcher.FilterDispatcher"?

  • Example

    by Sudip Kundu,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Can Anyone send a simple application developed with struts 2 ?

  • Re: I dont like the idea of Action helper interface

    by Nathan Hughes,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    so where you work, 'success' is not an option?

  • Re: I dont like the idea of Action helper interface

    by Mikel Masquefa,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    I agree with Karan's comment: the choice of terminology and its interpretation is totally related to the domain/application.

    My reason is very simple: many applications are developed by teams from countries who speak languages different from English and that don't want use english's words to determine webflow concepts.

    For example, instead of using the word 'success' I could want to use the word 'exito', spanish, or 'sucesso', portuguesse.

  • Inject things into actions

    by Thai Dang Vu,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    If we can inject the HttpServletRequest into an action, can we inject other things (e.g. a Spring bean)? The reason I ask this question is that I'm thinking of declaring a service bean in Spring which is bounded in a transaction (this feature is provided by Spring), then I have this service when I am in this action (no need to use <code>applicationContext.getBean("my service");</code>)

  • Re: Inject things into actions

    by Ian Roughley,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    yes - in fact spring injection come as a plugin to the framework.

  • How to Send form data to DAO Layer.

    by Rajagopal Y,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Hi,
    I Just started workign with Struts2.
    Here is my doubt.

    Assume that i am developing a loing application where user enters username and password, i have the setter/getter methods in my action for username& password.

    Form action i have to invoke the Service/DAO method, which takes a Value Object as paramater, which contains username& password.

    Here is few Questions:

    => Why can't we have a seperate bean for form properties and map it to the action class.
    => If the properties are defined in Action class, what is the right place to create the Value object (in my example with username& password).

    Any Suggestions....

  • some doubts

    by K Sathya Narayanan,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    hi
    i have a jsp named "displayEmployeeRecords.jsp"

    which should display the list of employee details like name , empid , salary

    i have implemeted this in struts1.2.

    i have implemented the action class and other xml files .


    i have a Arraylist object which contains a list of EmployeeModel object

    1)if Arraylist is empty then the action class should be called
    to populate the ArrayList
    else the ArrayList should be iterated to display its content
    2)tell me how to display this using struts2.0

    i have done this in struts 1.2 but i dont know how to call a Action class

    in Struts1.2-> /EmployeeData.do -> will call the Action class
    in Strut22.0->?

    in struts 1.2 -> logic:iterate to iterate the ArrayList and display the data
    in strut2.0->?

  • Re: I dont like the idea of Action helper interface

    by Edward Song,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    The idea of convention over configuration, I think is what is to be interpreted here, rather than the exact choice of string literals chosen for success and forward. In most conventions, actions have one of two results, success or failure. Providing "success" and "failure" as conventional string literal forwarding terms is just a convention over configuration feature, and can be overrided anyway by your choice of terminology.

  • Re: some doubts

    by Den hoss,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Struts2: /EmployeeData.action, <s:iterator></s:iterator>

  • How to get webapplication context

    by Sandeep Patil,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    I have action support usage in my struts1 application. My class if extended with struts2 action support then it throwns error because it misses on getWebApplicationContext method that was in struts1 action support class. How do you suggest to get that?

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

BT