• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Redirecting from one action to another, want to pass parameters

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a web page with hyper-links to different Struts action classes. When one hyper-link is clicked on the web page's form, I am redirecting control to another action. I am using javascript to pass some parameters to the first action. Now, I want to pass these parameters to the second action. But when I redirect, the servlet container creates a new request object, right ? I don't want to pass parameters in the url. Is using the session object my only other solution ? Will I be able to use forward action, ie, set redirect to false when I'm creating the new ActionForward for my destination ?

Thanks for your responses.

Mallika.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is one approach you can think of:

You can create hidden fields in the form which has links to other actions. And when the links are clicked, you can call a javascript function to populate the hidden fields with the corresponding values based on the clicked action. And ofcourse your form-bean for the current form should have the hidden fields also, declared as attributes with getters/setters for them.

-Rup
 
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

Is there any specific reason for uring redirect in ur action class to another action class ?? ofcourse redirect creates another request and u will loose the attributes but if u can send them in the url no issues .........

so better solution is use forward than redirect if u dont have any specific reason for this
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can put it in the request.setAttribute object and carry it around i guess
 
Mallika R Kumar
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks! Not using redirect solved the problem.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can use getRequestDispatch() to get a RequestDispatch, and add an attribute to the request, then forword this requestDispatch with request and response.It should be all right.
 
reply
    Bookmark Topic Watch Topic
  • New Topic