• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Capture array values in JSP

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67634
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
It's a beautiful day in this neighborhood - Fred Rogers. Tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic