This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
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

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Dynamic action forward?" Watch "Dynamic action forward?" New topic

Dynamic action forward?

Raj Chacko

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.



From my Action class and map in struts-config with something like this:
<action path"/tasknotify" scope="request"
type="" name="AgentNotifyForm"
input="/agentapp/dummy.jsp" validate="false">
<forward name="DynamicForward" path= "Variable containing dynamic
path"> </forward>
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

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 "/" with your dyamically generated path, but you get the idea.
[ October 19, 2004: Message edited by: Jason Menard ]
mary yaddah

Joined: Jul 31, 2013
Posts: 1
I had the same issue and couldnt find the answer but what I did was in you can use response.sendRedirect(""+yourVariable) instead of using a variable in path of struts-config.xml
I agree. Here's the link:
subject: Dynamic action forward?
It's not a secret anymore!