• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

action forward to servlet

 
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
Is/how it possible to forward from a action to a servlet at another url and preserve the parameters and session objects? I am doing all the processing in the Action and just simply need to send a data stream back. I can do it with servlets, but cant seem to do it with an action and a servlet. Can someone help me understand? tia.
 
Ranch Hand
Posts: 181
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your action create a new action forward with the url and parameters you want to send, then set redirect to true.

EDIT:
You can't send the session with this method.
[ April 30, 2007: Message edited by: Dom Lassy ]
 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.

From the action, you could use the getRequestDispatcher (it's in the ServletRequest interface). Then, you forward to the desired servlet. From inside a serlvet, you have access to the session and can retrieve any objects you want.

If you still have questions, please post your code. And make sure that what you're doing really makes sense. Usually, you shoudn't forward a request to a servlet from your action.
[ April 30, 2007: Message edited by: Leandro Melo ]
 
How do they get the deer to cross at the signs? Or to read this tiny ad?
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic