aspose file tools*
The moose likes Struts and the fly likes How to migrate from struts 1 to struts2? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to migrate from struts 1 to struts2?" Watch "How to migrate from struts 1 to struts2?" New topic
Author

How to migrate from struts 1 to struts2?

prabhu pandurangan
Ranch Hand

Joined: May 23, 2008
Posts: 132
Hi All,
Sorry, my post might be too expressive, but i could not find any other way... but please be patient and provide me some solutions for my quetions:
Its very urgent....(please buddies....)

Im currently working in struts 1 and my appication works fine.
I have used Iframe for tabbed panel in my jsp page. I have to remove iframe. When i looked for help... i found in struts 2 there is a tag <s:tabbedpanel>, but hw can i convert all my struts 1 business logic to struts 2 business logic.

Questions:
1. In struts 1, 'url://list.action?userid='2'&name='prabhu'.....etc'
we will be retriveing this parameter values in action class as:
String username = request.getParameter("userid");
How to use this in struts 2 application? as servlet concept is removed away from struts 2....? how to use?

2. in struts 1, if we need to get the value for list.jsp page, from action class we will be calling a DAO class and we retrieve the value and set the resultset to FormBean class and set that formBean to an ArrayList and return it.
example:

DAO class:

String query = "select userid, name from result";
resultset = statement.executeQuery(query);
ArayList userList = new ArrayList();
FormBean frm;
while(resultset.next())
{
frm = new FormBean();
frm.setUserid(resultset.getString("userid");
..
..
userList.add(frm);
}
return userList;

2: ACton class:
we will have the calling method as:

DAO dao = new DAO();
ArrayList list = new ArrayList();
list = dao.methodName(1,prabhu);
..
...
..

request.setAttribute("list", list);
return success;

3: jsp page

using scriptlet we will retrive that arraylist value and by using <logic:iterate>
we will build our business logic.

How to do this logics in struts 2...............?

Thanks
Prabhu.
[ May 23, 2008: Message edited by: Ulf Dittmer ]
Eric Nielsen
Ranch Hand

Joined: Dec 14, 2004
Posts: 194
Originally posted by prabhu rangan:
Hi All,
Im currently working in struts 1 and my appication works fine.
I have used Iframe for tabbed panel in my jsp page. I have to remove iframe. When i looked for help... i found in struts 2 there is a tag <s:tabbedpanel>, but hw can i convert all my struts 1 business logic to struts 2 business logic.

Well I'm a big fan of Struts 2; however I'm not sure you've made a good case for why you want to migrate... However to answer your questions...


1. In struts 1, 'url://list.action?userid='2'&name='prabhu'.....etc'
we will be retriveing this parameter values in action class as:
String username = request.getParameter("userid");
How to use this in struts 2 application? as servlet concept is removed away from struts 2....? how to use?

You action class will look like



2. in struts 1, if we need to get the value for list.jsp page, from action class we will be calling a DAO class and we retrieve the value and set the resultset to FormBean class and set that formBean to an ArrayList and return it.
example:

DAO class:

String query = "select userid, name from result";
resultset = statement.executeQuery(query);
ArayList userList = new ArrayList();
FormBean frm;
while(resultset.next())
{
frm = new FormBean();
frm.setUserid(resultset.getString("userid");
..
..
userList.add(frm);
}
return userList;

2: ACton class:
we will have the calling method as:

DAO dao = new DAO();
ArrayList list = new ArrayList();
list = dao.methodName(1,prabhu);
..
...
..

request.setAttribute("list", list);
return success;

3: jsp page

using scriptlet we will retrive that arraylist value and by using <logic:iterate>
we will build our business logic.


Step 1: Setup the action... (assuming you use spring to inject the dao)

Step 2: Use it in the jsp

[ May 23, 2008: Message edited by: Eric Nielsen ]
Eric Nielsen
Ranch Hand

Joined: Dec 14, 2004
Posts: 194
I greatly prefer Struts 2 to Struts 1. I wouldn't choose to start any new project in Struts 1, unless there were over-riding business policies/decisions.

I'm not sure how aggressive I would be about migrating existing applications, especially if the application works.

I find Struts 2 simpler and more enjoyable to work in. I don't know if that translates into any quantifiable efficiency gain, but I think it does. Of course the different project I've worked on in Struts 1 and Struts 2 are different enough to not allow any valid comparisons.
prabhu pandurangan
Ranch Hand

Joined: May 23, 2008
Posts: 132

Hi Eric,
Can you please go through your private message; I ahve posted two topics there for you to help;
Whenever you find time please go through and suggest me your ideas.

Thanks and Regards
Prabhu.

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42599
    
  65
prabhu,

please don't mistake Eric's willingness to help you in this forum with an offer to do so privately. Please RespectYourCoranchersPrivacy and UseTheForumNotEmail. You're more likely to get answers to your questions if everybody here can see them.


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to migrate from struts 1 to struts2?