File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Retrieving a drop-down list value. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Retrieving a drop-down list value." Watch "Retrieving a drop-down list value." New topic
Author

Retrieving a drop-down list value.

Jahnavi Kondapaneni
Ranch Hand

Joined: Jan 25, 2008
Posts: 56
Hi all,

I have a HTML form which displays a select drop-down list.I am using the "GET" method.
After the form is submitted I would like to retrieve the value selected in the drop down box within the servlet.
How do I do this?
Thanks in advance.


Regards,
Janu
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3838

Use,




SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9307
    
  17

Jahnavi if I am not mistaken, you must have done something like this



Now you just have to use request.getParameter("mySelect"); and it will return the value of the selected option. Remember it will not return Servlet or JSP or Struts, it will return the value attribute of the option tag i.e. either 1,2 or 3...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Jahnavi Kondapaneni
Ranch Hand

Joined: Jan 25, 2008
Posts: 56
Thanks guys its working fine.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Jahnavi Kondapaneni wrote:I am using the "GET" method.


why you are using GET to submit the form. always use POST with form
Jahnavi Kondapaneni
Ranch Hand

Joined: Jan 25, 2008
Posts: 56
Hi Seetharaman,

I did change the method from GET to POST...
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Good Jahnavi Kondapaneni .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Retrieving a drop-down list value.