jsp combine multiple values

G

grasp06110

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
 
L

Lew

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.
 
T

Tom Anderson

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
 
W

Wojtek

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.
 
T

Tom Anderson

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
 
W

Wojtek

Tom Anderson wrote :
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top