Re: JSP form submit does not overwrite request parameter value

Discussion in 'Java' started by VisionSet, Sep 2, 2003.

  1. VisionSet

    VisionSet Guest

    "Adam Lipscombe" <> wrote in message
    news:bj1pa8$e9b$...
    >
    > 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 paramter.
    >
    > i.e. <input name="myparam" .......>
    >
    >
    > Howecer, 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...


    Yes, multiple values of the same parameter name are allowed, this is how
    multiple selection SELECT inputs pass their choosen ones. There is no
    clever mechanism to distinguish between inputs that can only have one value.

    If you look at the HttpServletRequest interface docs you will see:

    public java.lang.String[] getParameterValues(java.lang.String name)
    Returns an array of String objects containing all of the values the given
    request parameter has, or null if the parameter does not exist.
    If the parameter has a single value, the array has a length of 1.

    --
    Mike W
     
    VisionSet, Sep 2, 2003
    #1
    1. Advertising

  2. Cool. Many thanks for enlightening me....

    Adam.



    "VisionSet" <> wrote in message
    news:6Z_4b.4066$...
    >
    > "Adam Lipscombe" <> wrote in message
    > news:bj1pa8$e9b$...
    > >
    > > 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 paramter.
    > >
    > > i.e. <input name="myparam" .......>
    > >
    > >
    > > Howecer, 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...

    >
    > Yes, multiple values of the same parameter name are allowed, this is how
    > multiple selection SELECT inputs pass their choosen ones. There is no
    > clever mechanism to distinguish between inputs that can only have one

    value.
    >
    > If you look at the HttpServletRequest interface docs you will see:
    >
    > public java.lang.String[] getParameterValues(java.lang.String name)
    > Returns an array of String objects containing all of the values the given
    > request parameter has, or null if the parameter does not exist.
    > If the parameter has a single value, the array has a length of 1.
    >
    > --
    > Mike W
    >
    >
     
    Adam Lipscombe, Sep 2, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. zalla rouge
    Replies:
    0
    Views:
    469
    zalla rouge
    Sep 2, 2003
  2. Guest
    Replies:
    2
    Views:
    1,605
    Guest
    Oct 25, 2004
  3. Megha Vishwanath
    Replies:
    3
    Views:
    720
    Megha Vishwanath
    Jul 20, 2004
  4. Florian Loitsch
    Replies:
    11
    Views:
    253
    Michael Winter
    Mar 15, 2005
  5. Replies:
    3
    Views:
    702
Loading...

Share This Page