Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Struts
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Struts
passing dynamic parameter in redirect
R .sourav nayak
Ranch Hand
Posts: 67
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
hi,
could some one send me some example how to pass dynamic parameter in redirect.
hoping some one to answer this
thanks
robert isidorson
Greenhorn
Posts: 19
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
For example :
ActionForward forward = new ActionForward("/youraction.do?id="+id,);
forward.setRedirect(true);
return forward;
You can also check out the ActionRedirect class in the documentation.
Brent Sterling
Ranch Hand
Posts: 948
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
A "feature" of
Struts
is that an ActionForward returned from findForward cannot be modified. Below is a utility method that I put together a while back to make it easy to add a dynamic parameter to an ActionForward.
public static ActionForward addParameterToForward( ActionForward forward, String paramName, String paramValue) { // define the new path StringBuffer newPath = new StringBuffer(); newPath.append(forward.getPath()); if (newPath.toString().indexOf('?') == -1) { newPath.append("?"); } else { newPath.append("&"); } newPath.append(paramName); newPath.append("="); newPath.append(paramValue); // copy the forward with the new path ActionForward newForward = new ActionForward(); newForward.setName(forward.getName()); newForward.setPath(newPath.toString()); newForward.setRedirect(forward.getRedirect()); newForward.setContextRelative(forward.getContextRelative()); return newForward; }
- Brent
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
?
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
redirect dynamic URL from action
dynamic/static ip
How to pass a dynamic parameter in struts-config.xml?
HTML Hidden value
returning Dynamic result pages in struts 2.0
More...