• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get values from dropdown Select box in JSP

 
Maddy Tillie
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gurus,
I have a JSP Page in which there are drop down select boxes, which are used to search sumthing. Basically i want to get the value selected by the user from drop down select boxes in my JSP. I just wanna show the search results based on the items selected and wanna show what the user has selected from those drop down boxes..
Thanks in advance..
Regards,
Maddy
 
Ali Gohar
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
You can do it by using getParameter method of request object. Suppose the name of the checkbox is "mycheckbox" then use following code:
String value = request.getParameter("mycheckbox");
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64623
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Maddy",
You'll find this forum a great place to seek help on JSP pages, and there aren't many rules you'll have to worry about, but one is that proper names are required. Please take a look at the JavaRanch Naming Policy and change your display name to match it.
In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.
Thanks!
bear
JSP Forum Bartender
 
Maddy Tillie
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But actually.. the form is submmited to a servlet, whcih is handling as a controller and then that servlet gets the search results and then again redirect to same JSP page.... so how do i get drop down variable in this case...
thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64623
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The name of the parameter will be the name you assigned to the select element. The value of this parameter will be the selected value.
 
prash po
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way to post all the values of a select box or at least all the selected values of a select box to a JSP page.
Like in a multiple selection select box how can I post all the values?
I would like to read all the possible values as well as all the selected values in the JSP.
As far as I know there is no way to do it. But if there is then please let me know.
- P P :roll:
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64623
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
posted May 12, 2004 02:05 PM Is there a way to post all the values of a select box or at least all the selected values of a select box to a JSP page.
Like in a multiple selection select box how can I post all the values?

The form will automatically post all selected option values. Each selected value will result in a request parameter with the name of the control and the value of the selected option. Be sure to use request.getParameterValues() when retrieving them.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic