This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes action forward to servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "action forward to servlet" Watch "action forward to servlet" New topic

action forward to servlet

Chris Pat
Ranch Hand

Joined: Aug 27, 2005
Posts: 156
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.
Dom Lassy
Ranch Hand

Joined: May 05, 2006
Posts: 181
In your action create a new action forward with the url and parameters you want to send, then set redirect to true.

You can't send the session with this method.
[ April 30, 2007: Message edited by: Dom Lassy ]
Leandro Melo
Ranch Hand

Joined: Mar 27, 2004
Posts: 401

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 ]

Leandro Melo
SCJP 1.4, SCWCD 1.4
subject: action forward to servlet
Similar Threads
Call servlet from action class
Forward Cannot Be Achieved In One Step
dynamic drop down list
How to show image from database
forwarding to a servlet instead of a jsp