Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get values from list to JSP

 
jeyaveera pandian
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,
I have wrote a program in JSP. I called that JSP from a HTML file in which i have created one list <select> with multiple selection mode. while i tried to get and print the selected values of that list using request.getParameter('listName'), it prints all the selected items of that list in a single line only.
I want to print all those selected items line by line. Plz help me in this regard.
Thanks in advance,
Anbudan,
K.Jeyaveerapandian
 
Angela Poynton
Ranch Hand
Posts: 3143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All I can think of at the moment is that you'll need to use StringTokenizer passing in the String you get back from the request and using a space as a delimiter, then use a while(tokenizer.hasMoreTokens()) loop to println each token in turn.
There may be a better way but I just can't think of it at the moment.
 
maha anna
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeyaveera pandian,
A small change in your code will do I think. Use getParameterValues method . It will return a String array of all values selected. Then you manuplate this String array according to your needs.

regds
maha anna
[This message has been edited by maha anna (edited December 05, 2000).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic