You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Steven Sajous <st...@dotmarketing.com> on 2003/05/23 00:17:24 UTC
modify a request parameter value
Is there a way to modify the value of a request parameter in struts. Let's
say I have .../do/something?dispatch=view and in the actionForm that handles
something I could set dispatch to something else before getting the mapping
for /do/nothing for example.
I used to do that in mod-perl if any of you guys have ever done perl
Steven Sajous
Application Engineer, Dotmarketing Inc.
http://www.dotmarketing.com
Re: modify a request parameter value
Posted by Ted Husted <hu...@apache.org>.
Struts uses the standard request object, so you can modify the
parameters in the usual way. See the Sun JavaDocs regarding the
HttpRequest object. But, be aware, there are scoping rules about what
happens when you do this.
In general, you would want to use the ActionForm to capture whatever
request parameters you are using. Then, you can use them in anyway you
like on the ActionForm. So, if there were a dispatch property on your
ActionForm, it would return "view" for you.
If I understand the use-case, the usual approach would to have the
Action check getDispatch and then return whatever forward is appropriate
(say findForward("nothing"). The Struts controller would then forward to
/do/nothing for you.
In general, we try to avoid forwarding from one Action to another, since
there can be side effects. Most people use something like the
DispatchAction so that one Action can handle several alternative tasks.
-Ted.
Steven Sajous wrote:
> Is there a way to modify the value of a request parameter in struts. Let's
> say I have .../do/something?dispatch=view and in the actionForm that handles
> something I could set dispatch to something else before getting the mapping
> for /do/nothing for example.
>
> I used to do that in mod-perl if any of you guys have ever done perl
>
> Steven Sajous
> Application Engineer, Dotmarketing Inc.
> http://www.dotmarketing.com
--
Ted Husted,
Struts in Action <http://husted.com/struts/book.html>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org