• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

How to get values from dropdown Select box in JSP

 
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
 
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");
 
Marshal
Posts: 67496
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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
Marshal
Posts: 67496
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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.
 
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
Marshal
Posts: 67496
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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.
 
Would anybody like some fudge? I made it an hour ago. And it goes well with a tiny ad ...
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic