I wrote an extension to help me do this. I use this in all my projects. http://www.rabago.net/struts/redirect
hth, Hubert --- Jay Glanville <[EMAIL PROTECTED]> wrote:> > I'm trying to solve a problem, but I'm not sure my solution > is the best > way. Basically, I want to set a parameter on a forward within the > action's execute. > > I'm in my action's execute method. I've just successfully performed > some work, and I now want to forward/redirect to the next page. So, > I've got some code that looks like this: > > public ActionForward execute(ActionMapping.....) { > // do some work > ActionForward goto = mapping.findForward( "success" ); > return goto; > } > > With an action mapping that looks like this: > > <action > path="/EntrySave" > type="com.package.EntrySaveAction" > name="EntryForm" > validate="true" > input="/Entry.do"> > <forward name="success" redirect="true" path="/Container.do"/> > <forward name="failure" redirect="false" path="/Entry.do" /> > </action> > > Basically, if I left the EntrySaveAction.execute do what's doing right > now, then upon successful completion, it would redirect to > "/Container.do". However, what I want it to do is redirect to > "/Container.do?id=45", where 45 is the id of the container that I want > to go to. The value of "45" is dynamic, and is know at the > time of the > EntrySaveAction.execute command. > > The way I'm currently doing it is something like this: > > public ActionForward execute(ActionMapping.....) { > // do some work > ActionForward goto = mapping.findForward( "success" ); > String path = goto.getPath(); > path += "?id=" + container.getId(); > goto.setPath( path ); > return goto; > } > > Is this the correct way to do this? Is there a better way? > > Thanks in advance > > JDG > > > -- > Jay Glanville __________________________________ Do you Yahoo!? Yahoo! Mail - More reliable, more storage, less spam http://mail.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]