aspose file tools*
The moose likes Struts and the fly likes Dynamic action forward? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Dynamic action forward?" Watch "Dynamic action forward?" New topic
Author

Dynamic action forward?

Raj Chacko
Greenhorn

Joined: Oct 18, 2004
Posts: 1
I would like to know if there is a way to pass a variable to the path properties of the <forward /> tag for a specific action within the Struts-Config.xml.

Ex:

mapping.findForward("DynamicForward");

From my Action class and map in struts-config with something like this:
<action path"/tasknotify" scope="request"
type="sync.server.contact.AgentNotify" name="AgentNotifyForm"
input="/agentapp/dummy.jsp" validate="false">
<forward name="DynamicForward" path= "Variable containing dynamic
path"> </forward>
</action>
Has anyone come across a solution for this issue (<forward name="DynamicForward" path= "Variable containing dynamic path" </forward> ?
Thanks in Advance
Raj Chacko
sreenath reddy
Ranch Hand

Joined: Sep 21, 2003
Posts: 415
HI raj

There is no way u can make ur path variable dynamic as once the config file is loaded it will be freezed mean to say that u cant set the path ..................but the same thing can be achieved( i mean to say the path will be fixed an just u need to pass different variables with diff values) before forwading them set them in request scope and u will be able to access them in ur resource ....................

i hope u got what i am saying u cant get back if u have any issues in this
Jason Menard
Sheriff

Joined: Nov 09, 2000
Posts: 6450
Another thing you can do is dynamically generate a new ActionForward object that your Action can return. For example, in your action you might have the following:



Naturally you will want to replace "/myAction.do" with your dyamically generated path, but you get the idea.
[ October 19, 2004: Message edited by: Jason Menard ]
mary yaddah
Greenhorn

Joined: Jul 31, 2013
Posts: 1
I had the same issue and couldnt find the answer but what I did was in Action.java you can use response.sendRedirect("http://google.com/"+yourVariable) instead of using a variable in path of struts-config.xml
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dynamic action forward?
 
Similar Threads
passing dynamic parameter using action
getting ClassNotFoundException
Getting the Parser Error struts
help for action?
How to pass a dynamic parameter in struts-config.xml?