[prev in list] [next in list] [prev in thread] [next in thread] 

List:       struts-user
Subject:    Re: action forward to servlet
From:       Chris Pat <cpanon () yahoo ! com>
Date:       2007-04-30 21:20:48
Message-ID: 608672.98282.qm () web60117 ! mail ! yahoo ! com
[Download RAW message or body]


Hi Laurie
I had used Request.dispatcher before but only in servlet code; didnt know/realize I \
could do it in an Action.  I see the key is to make that one of the states that will \
always be called and just trick Struts with the return of the null.  I assume the \
technology is orthogonal enough that if I have a browser page, or open a url to the \
Action it will be automatically be "fed" the output of the Request.dispatcher from \
the servlet.  That would be very elegant.

Laurie Harper <laurie@holoweb.net> wrote: The first question should be, do you really \
need the servlet? You could  generate the full response from the action. If you still \
need to keep  the servlet around for other uses, perhaps you can refactor the bulk of \
 its work into a service class that both the servlet and the action can 
use to generate the response.

Failing that, the way to do this is to manually dispatch to the servlet 
(using request.getDispatcher("/servlet/path").forward() or something 
like that; I forget the exact API). Then be sure to return 'null' from 
your action to tell Struts it shouldn't do anything further with the 
response.

HTH,

L.

Felipe Rodrigues wrote:
> Preserver de session?
> Session is already preserved. Did you try that?
> To get values from session in your servlet you must use Session ses =
> request.getSession().
> Than you have your session object. Parameters from request? You should use
> request.getParameters().
> To get Action fields, well I'm not sure what struts you're using, but maybe
> you can use ActionContext class to get that.
> 
> Regards,
> 
> Felipe
> 
> 
> cpanon wrote:
> > 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.
> > 
> > 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic