my dog learned polymorphism*
The moose likes Servlets and the fly likes Problem retreiving the value of select option Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Problem retreiving the value of select option" Watch "Problem retreiving the value of select option" New topic
Author

Problem retreiving the value of select option

Saumyaraj Zala
Ranch Hand

Joined: Aug 06, 2012
Posts: 56

I have a select tag in my form which is to be send to Servlet. I have made the contents of the select tag dynamic(it gets values from a table column in DB).
('r' is ResultSet)
My problem is how can i send the value the user has selected from select tag to servlet. For using Request.getparameter("name") I must know the value of option tag.
I my confused.Please help..
Thanks.


Why do we fall? So that we can learn to pick ourselves up.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60765
    
  65

Just like any other HTML page, the value of the submitted parameter for the select element will be the value of the selected option.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Niraj Jha
Ranch Hand

Joined: Feb 20, 2013
Posts: 63

as @Bear said just call request.getParameter("name").
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60765
    
  65

Of course, you've got to give your select element a name.
Lalit Mehra
Ranch Hand

Joined: Jun 08, 2010
Posts: 384

Whenever there's a need to fetch the submitted values to the Servlet ...
always make sure to name the HTML elements whose values are required.

then using


you can easily get the entered value or in your case the selected value.

http://plainoldjavaobject.blogspot.in
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem retreiving the value of select option
 
Similar Threads
how to get the <select> tag value from one jsp page to another jsp page during file uploading time?
html:options tag help ASAP
IE not taking &nbsp; characters
doubt
taglibs problem