From: "Nimmons, Buster" <[EMAIL PROTECTED]> Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]> Subject: RE: forwarding to action needing different request parameters Date: Wed, 12 May 2004 15:18:06 -0500
I really don't want to modify the second servlet since it's already in production. Also the ActionForm associated with my Action does not have the member variable needed by the second servlet. I really didn't want to add fields to the ActionForm that weren't needed for this Action
-----Original Message----- From: None None [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 12, 2004 3:10 PM To: [EMAIL PROTECTED] Subject: RE: forwarding to action needing different request parameters
I see what you mean... But, and again, I am new to Struts, I think the
ActionForm is already in the request object, and since it was passed by
reference to your Action's execute() method, you are altering the ActionForm
itself (pass by reference? For some reason I always get pass by reference
and pass by value reversed)... So, in your first Action, setting the
parameters in the ActionForm basically means that the ActionForm in the
request object now has those values... So, if you call the doPost() method
of your second servlet (or forward to it, shouldn't matter), that servlet
can just pull out the ActionForm and then the parameters from that. This of
course assumes you can alter that servlet, which maybe is a bad assumption
on my part since if you could then you'd probably just make it an Action
class and be done with it, but if you can alter it then this should work.
Otherwise, as was suggested by someone else, just append the parameters as a
query string to the forward to the servlet (remembering to URL encode them for safety), I think that would be your best bet.
>From: "Nimmons, Buster" <[EMAIL PROTECTED]>
>Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
>To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
>Subject: RE: forwarding to action needing different request parameters
>Date: Wed, 12 May 2004 14:49:54 -0500
>
>I see what you are saying about using the ActionForm.. The forward I'm
>mapping to is not a Struts action but a servlet mapping specified in the
>web.xml.. It's an older servlet created before we started using struts so
>it
>does have to get the required parameters from the request object
>
>-----Original Message-----
>From: None None [mailto:[EMAIL PROTECTED]
>Sent: Wednesday, May 12, 2004 2:44 PM
>To: [EMAIL PROTECTED]
>Subject: RE: forwarding to action needing different request parameters
>
>
>I'm pretty new to Struts, and it's entirely possible I'm not following what
>your saying, but...
>
>If the first Action is getting an ActionForm with the four parameters
>populated, you can simply instantiate the second Action, passing it the
>ActionForm, and then return from the first Action the ActionForward
>returned
>
>by the second (or to another of the first, whatever you need).
>
>Likewise, you can always instantiate your own ActionForm instance and pass
>that to the second Action, setting it up however you wish.
>
>If I'm getting what your saying, I think it's as easy as that. But, it
>sounded like you are maybe grabbing the request parameters directly from
>the
>
>request object instead of using an ActionForm... if that's the case,
>there's
>
>still nothing to stop you from using an ActionForm for the second Action as
>input. That way you could populate the original request parameters, or put
>new values in their place, whatever you want.
>
>I can tell you that adding parameters to the request object it not allowed,
>although I remember something about that being added in a later servlet
>spec. I do not know what version it IS allowed in, if that version even
>exists yet.
>
>
> >From: "Nimmons, Buster" <[EMAIL PROTECTED]>
> >Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> >To: "Struts2 (E-mail)" <[EMAIL PROTECTED]>
> >Subject: forwarding to action needing different request parameters
> >Date: Wed, 12 May 2004 13:55:52 -0500
> >
> >I have an Action which is usualy accessed from an html form page... It
> >requires 4 request parameters. I need to forward to this action from
> >another
> >action but the action I'm forwarding from does not have all 4 of the
> >reuired
> >request parameters. I know what the value of the parameters should be but
>I
> >cannot put them in the request scope unless I use request.setAttribute()
> >however the action being forwarded to is not looking for the required
> >parameters from the Attributes but the requestParametes.. has anyone
> >figured
> >out an easy way to modify the available requestParameters before
>forwarding
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >
>
>_________________________________________________________________
>FREE pop-up blocking with the new MSN Toolbar - get it now!
>http://toolbar.msn.com/go/onm00200415ave/direct/01/
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
_________________________________________________________________ Is your PC infected? Get a FREE online computer virus scan from McAfee® Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar – get it now! http://toolbar.msn.com/go/onm00200415ave/direct/01/
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]