This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Struts and the fly likes Newbie: Struts 1 -> Passing from one struts action to another Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Newbie: Struts 1 -> Passing from one struts action to another" Watch "Newbie: Struts 1 -> Passing from one struts action to another" New topic
Author

Newbie: Struts 1 -> Passing from one struts action to another

Anup Bansal
Ranch Hand

Joined: Sep 12, 2006
Posts: 69
Hi,

I have two questions w.r.t struts. Following is an example of my action mapping:

<action path="/actions/firstAction"
type="example.SecurityAction"
scope="request">
<forward name="success"
path="/actions/secondAction.do"/>
<forward name="failure"
path="/pages/login.jsp"/>
</action>

<action path="/actions/secondAction"
type="example.BusinessAction"
scope="request">
<forward name="success" page="/pages/businessPage.jsp"/>
</action>

1. How can i pass objects from one action class to another? Say from FirstAction to SecondAction
Can i use request.setattribute in the first action class to set the object and get in the second action using request.getattribute, which i can then set in the form of the seconAction?
If i define a third action class, will the object set in the first action also be accessible in the third action class (without me setting it again explicitly in the second action class)?
Are there any implications of using request.setattribute?

2. Is it better to set the object in some database on form submission in the first action class and then retrieve it in the second action class from the database, set it in the form bean for display in the jsp?
 
Consider Paul's rocket mass heater.
 
subject: Newbie: Struts 1 -> Passing from one struts action to another