• Post Reply Bookmark Topic Watch Topic
  • New Topic

Query reg getting Collection of Options in JSP  RSS feed

 
Abrahim Daver
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Is it possible to get a collection of SelectOption combo box, if multiple selection is set to true, in JSP page. In usual way, we get a string value of those selected options(with request). Is there any way to get them in to collection directly.
Any help will be highly appreciated.
ThanX,
Abra.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is nothing that I am aware of in the servlet API that allows you to do this. There might be a third party library out there that takes an HttpServletRequest and throws arrays into a Collection, but I don't know of one. Seems like a simple solution though. Why not just write a method that does this yourself and then reuse it?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any time the browser sends back multiple parameters with the same name (which is what happens with a multi select list), you can retrieve the values as a String[] with request.getParameterValues.

You can then loop through the array and load them into a collection if you wish
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!