You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Hertenstein Alain <al...@gva.eri.ch> on 2003/09/02 13:25:06 UTC

RE : JSP form submit does not overwrite request parameter value

Hi,

>I have a JSP that contains a form with some input fields. This JSP is
called and passed a parameter in the request object.
>i.e. http://<page_url>?myparam=abc
>One of the input fields in the form has the name as the parameter.
>i.e. <input name="myparam" .......>

I don't understand your need of setting a parameter in the target form page,
while the same parameter already exists inside the form ? Maybe you better
set a different parameter name for value 'abc' (like ?myparam2=abc)...

>However, when the form is submitted the original value that in the request
"myparam" parameter does not get overwritten by >the value that is entered
into the input field.
>Is this behaviour correct? I would have expected that the input field value
would overwrite the original "myparam"  >value...

This behaviour is correct, I just tested it and it works this way.
BUT, I have the solution for you : a parameter can have multiple values.
For your case, you can get all values of "myparam" parameter by using the
request.getParameterValues("myparam") method. You'll get a String array
containing all values, i.e. "abc" as the 1st value, then the value which was
set in your form as the 2nd value.

Just tried it and it works.
Hope it helps.
Alain


**********************************************************************
 This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**********************************************************************


RE: RE : JSP form submit does not overwrite request parameter value

Posted by Adam Lipscombe <ad...@cobar.fsbusiness.co.uk>.
Cool - Many thanks!

Adam

-----Original Message-----
From: Hertenstein Alain [mailto:alhertenstein@gva.eri.ch] 
Sent: 02 September 2003 12:25
To: 'Tomcat Users List'
Subject: RE : JSP form submit does not overwrite request parameter value


Hi,

>I have a JSP that contains a form with some input fields. This JSP is
called and passed a parameter in the request object.
>i.e. http://<page_url>?myparam=abc
>One of the input fields in the form has the name as the parameter.
>i.e. <input name="myparam" .......>

I don't understand your need of setting a parameter in the target form
page,
while the same parameter already exists inside the form ? Maybe you
better
set a different parameter name for value 'abc' (like ?myparam2=abc)...

>However, when the form is submitted the original value that in the
request
"myparam" parameter does not get overwritten by >the value that is
entered
into the input field.
>Is this behaviour correct? I would have expected that the input field
value
would overwrite the original "myparam"  >value...

This behaviour is correct, I just tested it and it works this way.
BUT, I have the solution for you : a parameter can have multiple values.
For your case, you can get all values of "myparam" parameter by using
the
request.getParameterValues("myparam") method. You'll get a String array
containing all values, i.e. "abc" as the 1st value, then the value which
was
set in your form as the 2nd value.

Just tried it and it works.
Hope it helps.
Alain


**********************************************************************
 This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**********************************************************************


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