You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Phase Communcations <ma...@phase.ws> on 2002/02/22 13:07:50 UTC

Changing Request Parameters

I am forwarding from one Action to Another. I need to tweak the request
parameters. Is there a way to do this?

I tried to set the reqest value by calling the FormBean and set it from the
action. But, it doesn't carry over to the next Action. I can't find a way to
change the request parameters. Please help.

I saw some discussion on the archive. But, is pretty aimless and not very
clear.

I am running Servlet 2.2 so don't tell me about getParameterMap().

Brandon Goodin
Phase Web and Multimedia
P (406) 862-2245
F (406) 862-0354
mail@phase.ws
http://www.phase.ws



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Changing Request Parameters

Posted by Michael Baldwin <mi...@sun.com>.
Since you're forwarding from Action to Action, you do have a minor issue.  Things
you set in the request will be reset after the forward.

Solution 1: add what you need to the session.
Solution 2: extend ActionForward with a subclass that takes a map of name value
pairs to stick in the request.  Override the getPath() method to return the path
for the forward, plus the query string to follow it.  (e.g. String getPath() {
returns something like /myAction.do?mapParam1=val1&mapParam2=val2 )

You'll probably want to create this ActionForward yourself (MyActionForward f =
new MyActionForward(path, paramMap) );  You just need to be careful that the
ActionForward doesn't get reused (for obvious reasons).  I believe that the
ActionForwards in struts are static so if you use mapping.findForward("foo"), and
then add params to that, I think other actions might see them.  I'm not sure.

You could probably write your action forward to take an action forward in its
constructor such that you can reuse the static one in your dynamic one (if it is
static indeed).  i.e., MyActionForward f = new MyActionForward
(mapping.findForward("foo"), Map paramMap)


cheers,
--Michael


Phase Communcations wrote:

> I am forwarding from one Action to Another. I need to tweak the request
> parameters. Is there a way to do this?
>
> I tried to set the reqest value by calling the FormBean and set it from the
> action. But, it doesn't carry over to the next Action. I can't find a way to
> change the request parameters. Please help.
>
> I saw some discussion on the archive. But, is pretty aimless and not very
> clear.
>
> I am running Servlet 2.2 so don't tell me about getParameterMap().
>
> Brandon Goodin
> Phase Web and Multimedia
> P (406) 862-2245
> F (406) 862-0354
> mail@phase.ws
> http://www.phase.ws
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


and action

Posted by Henry Lu <zh...@umich.edu>.
I got error:
javax.servlet.ServletException: MultipartIterator: no multipart request


my JSP file has:
<html:form method=post action="/saveIdForm" enctype="multipart/form-data">
<html:file property="myfile"/>
...

and my ActionForm has:

private FormFile myfile;

// getter and setter

What is wrong?


---------------------------------------------------------------------------
Henry Lu
MCIT                                            phone: (734) 936-2063
University of Michigan Medical Center           fax:   (734) 763-4372



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: NEVERMIND: Changing Request Parameters

Posted by Ted Husted <hu...@apache.org>.
Phase Communcations wrote:
> I tried to set the reqest value by calling the FormBean and set it from the
> action. But, it doesn't carry over to the next Action. I can't find a way to
> change the request parameters. Please help.

The trick is to put a switch on your form bean to make it immutable.
This way the controller can't mess with it between actions. 


    private boolean mutable = true;
    public void setMutable(boolean mutable) {
        this.mutable = mutable;
    }
    public boolean isMutable() {
        return this.mutable;
    }

    public String whatever = null;
    public void setWhatever(String whatever) {
        if (isMutable()) this.whatever = whatever;
    }
    public String getWhatever() {
        return this.whatever;
    }

Then be sure that reset uses the setters (and doesn't clear mutable).


-- Ted Husted, Husted dot Com, Fairport NY US
-- Developing Java Web Applications with Struts
-- Tel: +1 585 737-3463
-- Web: http://husted.com/about/services

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: NEVERMIND: Changing Request Parameters

Posted by Jin Bal <ji...@hotmail.com>.
Equally cheesy would be  to set request attributes and get the receiving
action to check the attributes before checking the req params.  It's dirty I
know, but it may be slightly preferable to constructing query strings on the
server and creating a new request.......

Just a thought.

HTH
Jin
----- Original Message -----
From: "Phase Communcations" <ma...@phase.ws>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Friday, February 22, 2002 12:16 PM
Subject: NEVERMIND: Changing Request Parameters


> A little more research and I find that it is not possible and that I need
to
> rebuild the and redirect. Cheezy.
>
> -----Original Message-----
> From: Phase Communcations [mailto:mail@phase.ws]
> Sent: Friday, February 22, 2002 5:08 AM
> To: Struts Users Mailing List
> Subject: Changing Request Parameters
>
>
> I am forwarding from one Action to Another. I need to tweak the request
> parameters. Is there a way to do this?
>
> I tried to set the reqest value by calling the FormBean and set it from
the
> action. But, it doesn't carry over to the next Action. I can't find a way
to
> change the request parameters. Please help.
>
> I saw some discussion on the archive. But, is pretty aimless and not very
> clear.
>
> I am running Servlet 2.2 so don't tell me about getParameterMap().
>
> Brandon Goodin
> Phase Web and Multimedia
> P (406) 862-2245
> F (406) 862-0354
> mail@phase.ws
> http://www.phase.ws
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


NEVERMIND: Changing Request Parameters

Posted by Phase Communcations <ma...@phase.ws>.
A little more research and I find that it is not possible and that I need to
rebuild the and redirect. Cheezy.

-----Original Message-----
From: Phase Communcations [mailto:mail@phase.ws]
Sent: Friday, February 22, 2002 5:08 AM
To: Struts Users Mailing List
Subject: Changing Request Parameters


I am forwarding from one Action to Another. I need to tweak the request
parameters. Is there a way to do this?

I tried to set the reqest value by calling the FormBean and set it from the
action. But, it doesn't carry over to the next Action. I can't find a way to
change the request parameters. Please help.

I saw some discussion on the archive. But, is pretty aimless and not very
clear.

I am running Servlet 2.2 so don't tell me about getParameterMap().

Brandon Goodin
Phase Web and Multimedia
P (406) 862-2245
F (406) 862-0354
mail@phase.ws
http://www.phase.ws



--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>