jsp combine multiple values

Discussion in 'Java' started by grasp06110@gmail.com, Feb 8, 2009.

  1. Guest

    Hi Everybody!

    I have a page that has several inputs with multiple parts For
    example, I have 5 records and each has a name field, a rank field, and
    a serial number field. My understanding is that if this form is
    submitted to a servlet there is no assurance that the parameters will
    be processed in order so if I want to keep the first rank and id with
    the first name I can't just iterate through the respective collections
    returned by getParameter("name"), getParameter("rank"), getParameter
    ("serialNumber"). Is there an easy way to correctly associate the
    name, rank, and serial numbers for the 5 individuals that insures they
    wont get mixed up? Is there a framework that handles this well?

    Thanks,
    John
    , Feb 8, 2009
    #1
    1. Advertising

  2. Lew Guest

    wrote:
    > Hi Everybody!
    >
    > I have a page that has several inputs with multiple parts For
    > example, I have 5 records and each has a name field, a rank field, and
    > a serial number field. My understanding is that if this form is
    > submitted to a servlet there is no assurance that the parameters will
    > be processed in order so if I want to keep the first rank and id with
    > the first name I can't just iterate through the respective collections
    > returned by getParameter("name"), getParameter("rank"), getParameter
    > ("serialNumber"). Is there an easy way to correctly associate the
    > name, rank, and serial numbers for the 5 individuals that insures they
    > wont get mixed up? Is there a framework that handles this well?


    Give each input field a different name.

    --
    Lew
    Lew, Feb 8, 2009
    #2
    1. Advertising

  3. Tom Anderson Guest

    On Sun, 8 Feb 2009, wrote:

    > I have a page that has several inputs with multiple parts For example, I
    > have 5 records and each has a name field, a rank field, and a serial
    > number field. My understanding is that if this form is submitted to a
    > servlet there is no assurance that the parameters will be processed in
    > order so if I want to keep the first rank and id with the first name I
    > can't just iterate through the respective collections returned by
    > getParameter("name"), getParameter("rank"), getParameter
    > ("serialNumber"). Is there an easy way to correctly associate the name,
    > rank, and serial numbers for the 5 individuals that insures they wont
    > get mixed up?


    You have to give the fields different names. For instance:

    record.0.name
    record.0.rank
    record.0.serialNumber
    record.1.name
    record.1.rank
    record.1.serialNumber
    record.2.name
    record.2.rank
    record.2.serialNumber

    etc. Alternatively:

    name.0
    rank.0
    serialNumber.0
    name.1
    rank.1
    serialNumber.1
    name.2
    rank.2
    serialNumber.2

    > Is there a framework that handles this well?


    I know next to nothing about web frameworks, so i can't answer that, but i
    strongly suspect that most of the big ones do.

    tom

    --
    Yulava? Niob Yam!
    Tom Anderson, Feb 8, 2009
    #3
  4. Wojtek Guest

    wrote :
    > My understanding is that if this form is
    > submitted to a servlet there is no assurance that the parameters will
    > be processed in order so if I want to keep the first rank and id with
    > the first name


    Where did you read this?

    In browsers I have tested against (SeaMonkey, IE, Firefox) the values
    were kept together.

    --
    Wojtek :)
    Wojtek, Feb 8, 2009
    #4
  5. Tom Anderson Guest

    On Sun, 8 Feb 2009, Wojtek wrote:

    > wrote :
    >> My understanding is that if this form is
    >> submitted to a servlet there is no assurance that the parameters will
    >> be processed in order so if I want to keep the first rank and id with
    >> the first name

    >
    > Where did you read this?
    >
    > In browsers I have tested against (SeaMonkey, IE, Firefox) the values
    > were kept together.


    I think the HTML specification mandates it, actually, but i wouldn't want
    to rely on it.

    tom

    --
    A is for Absinthe, for which I now thirst
    Tom Anderson, Feb 9, 2009
    #5
  6. Wojtek Guest

    Tom Anderson wrote :
    > On Sun, 8 Feb 2009, Wojtek wrote:
    >
    >> wrote :
    >>> My understanding is that if this form is
    >>> submitted to a servlet there is no assurance that the parameters will
    >>> be processed in order so if I want to keep the first rank and id with
    >>> the first name

    >>
    >> Where did you read this?
    >>
    >> In browsers I have tested against (SeaMonkey, IE, Firefox) the values were
    >> kept together.

    >
    > I think the HTML specification mandates it, actually, but i wouldn't want to
    > rely on it.


    Really?

    Well then do a test at login. Place a couple of hidden value pairs
    within the login form, then test them when the user cliks on the login
    button.

    If the values are out of sync, then log it (to create browser stats)
    and inform the user with some helpful message.

    --
    Wojtek :)
    Wojtek, Feb 9, 2009
    #6
    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. Replies:
    0
    Views:
    4,330
  2. Replies:
    0
    Views:
    775
  3. Frank Reiff
    Replies:
    9
    Views:
    136
    Frank Reiff
    Mar 27, 2007
  4. Replies:
    1
    Views:
    995
    Prasad, Ramit
    Feb 16, 2012
  5. Clint Olsen
    Replies:
    2
    Views:
    146
    Clint Olsen
    Jun 29, 2004
Loading...

Share This Page