Forums Register Login

getParameter question

+Pie Number of slices to send: Send
i have 2 jsps, where
jsp1 has a form and submits a dynamic number of textboxes and combo boxes
and
jsp2 which receives those submitted

now, in jsp1, my textbox names are arrays, as in:



and how do i get those values in my jsp2?
i need to retrieve all the values inputted in the dynamic number of textboxes i have

thanks
+Pie Number of slices to send: Send
i solved some of the problem:
i tried it with textboxes but it still doesn't work with combo boxes

this is what i did



and in jsp2


but if i do the same thing with combo boxes, it doesn't work

<select name="combo1">
<option value="1">1</option>
<option value="2">2</option>
</select>

and same as in jsp2
+Pie Number of slices to send: Send
If your fields are named field0, field1, field2, field3..., then you have to retrieve the parameters under the names field1, field2, field3

ie


This code doesn't need to know how many items there are. It assumes when it doesn't find an item, that there are no more. That works for textboxes/select items, but won't work for checkboxes.


On request.getParameterValues(): this gets all the values for parameter.
eg reading=Headfirst Java&reading=Struts in Action&reading=Design Patterns
All of these have the same parameter name, but multiple values were submitted. However there is no guaruntee on the order of those parameters. In your case if the textbox and select box are linked, you can't be sure that you match them up correctly unless you number them yourself.

Also there is a useful package in the jakarta commons: BeanUtils.
If you name your fields field[0], field[1], field[2] then it will automagically retrieve them as array fields. (This is used in Struts)

Hope some of this helps,
evnafets
+Pie Number of slices to send: Send
thanks very much.

you're a very good teacher.
i'll try your code.
i'm just not too sure about the struts thing though. i don't know how it works and how to use it

thanks again
+Pie Number of slices to send: Send
I woud not adopt Struts for something so trivial.
We must storm this mad man's lab and destroy his villanous bomb! Are you with me tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1240 times.
Similar Threads
problem with iframe and javascript
passing object from one jsp to another using session
dynamic text boxes
getParameterValues problem
Setting window size on load
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 17:52:41.