File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Select value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Select value " Watch "Select value " New topic

Select value

vasuma patel

Joined: Mar 07, 2006
Posts: 15
How do I get the selected value of a dropdown box( HTML select) from request object?

Thanks in advance

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63868

With getParameter() just like any other form element.

[Asking smart questions] [About Bear] [Books by Bear]
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

Note that you'll get the value of the selected option, not the text displayed in the combobox.

[My Blog]
All roads lead to JavaRanch
vasuma patel

Joined: Mar 07, 2006
Posts: 15
Ok.. Thanks. I was using getParameter() but am getting null and so thought there is something different to do with select. I will check what I was doing wrong.
Uma Mahi
Ranch Hand

Joined: Jan 11, 2006
Posts: 34
<option value="test">test</option>

set the value attribute for the option tag

Umaa Mahi<br />--SCJP1.4
sushma sree

Joined: Mar 27, 2006
Posts: 12
Your code should look something like this:

<select name="selectedItem">
<option value="1">Value1</option>
<option value="2">Value2</option>

And in your code, you can retrieve it using


Incase you have a list box rather than a select box like

<select name="selectedItems" multiple>
<option value="1">Value1</option>
<option value="2">Value2</option>

your code should then be

I agree. Here's the link:
subject: Select value
It's not a secret anymore!