Help coderanch get a
new server
by contributing to the fundraiser
  • 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

Q: dynamic forwarding with DispatchAction

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I have the following situation: A DispatchAction contains a number of methods that can be called and that all return an ActionForward. Every method returns to the same URL upon success. I want to add a separate parameter in every method to the success URL. How can I do this without having to explicitly set the path of the forward (using setPath()) ?

For example:
DispatchAction doSomething has two methods methodA and methodB. They both forward to result.jsp. In result.jsp I want to display the sentence "Method X has been successfully executed", replacing X by either A or B. What is the best way to achieve this ? I prefer no solutions that explicitly place data in the session variable.
 
Ranch Hand
Posts: 415
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

U can achieve this in two ways .u have a method called request.getQueryString() method ......from there u can retrive the string as like method=MethodA ...then u perform some logic to get the value ................
 
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You may also create a hidden parameter in the JSP, which will be captured by the Form.



and for different methods, you have set a different value to the forwardTo parameter, and inside the DispatchAction, you can:



Then, you can perform the dynamic forwarding.
I am currently using this approach.

Nick
 
Karel KoboojBot
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Nick and reddy
 
There is no beard big enough to make me comfortable enough with my masculinity to wear pink. Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic