• Post Reply Bookmark Topic Watch Topic
  • New Topic

Capture array values in JSP

 
Steve Bradley
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi gang,

I am working on a JSP page that loops through an unknown number of
javabeans and displays descriptions / Quantity in a list format. NoProblems.

User will enter numeric value in textfield provided on each line.

How do I 'capture' the user-data at the time the SUBMIT button is clicked.

Or is this a javascript question?






Steve
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If order is not important, you can give all the elements the same name and use getParameterValues() in the servlet to which you are submitting in order to retrieve them as a string array.

Otherwise, retrieve them the same way you created them: a loop using the indexes as the suffix to the name using getParameter() to get the value of each. You can stop the loop when you get a null back, or include a hidden parameter in the form with the number of elements you created.

No javascript.
[ October 28, 2004: Message edited by: Bear Bibeault ]
 
Steve Bradley
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear,

Thank you for your idea, I tried the first one and it works!!!

If I could ask one more...
Your second suggestion to build an array in the JSP - I like this but how to instruct the array to get values AFTER the submit button is clicked?

Thanks Again,
Steve
 
Steve Bradley
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wait Bear,

Im reading your note again and I see clearly that the array should be built from the servlet.

Please disregard my recent reply.

Steve
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!