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 How to read from a drop down in Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to read from a drop down in Servlet" Watch "How to read from a drop down in Servlet" New topic
Author

How to read from a drop down in Servlet

Hrishikesh Ghatnekar
Greenhorn

Joined: Oct 25, 2004
Posts: 28
Hi,

I have one html which contains a dropdown list. I want to read the value of the selected item in the dropdown in my servlet.

I tried with following things , but it didn�t worked

In Html
<SELECT NAME="xyz">

In Servlet

Request.getParameter(�xyz �)

But this is returning null


What can be done Here?

Thanks
Hrishikesh
Niki Nono
Ranch Hand

Joined: Mar 20, 2005
Posts: 256
check if the value xyz is there in the URL by changing your method of form to get.
if it is not there then your select box is not in your form.
please try and reply.


Life called,so here I am.<br />Cheers<br />Niki.:-)
Neeraj Dheer
Ranch Hand

Joined: Mar 30, 2005
Posts: 225
if a particular parameter has more than one value, all the values can be retreived by

String []allValues = Request.getParameterValues("name");

this is after verifying that the drop-down is in the form of course.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Hrishikesh Ghatnekar:
Hi,
I have one html which contains a dropdown list. I want to read the value of the selected item in the dropdown in my servlet.
I tried with following things , but it didn�t worked
In Html
<SELECT NAME="xyz">
In Servlet
Request.getParameter(�xyz �)
But this is returning null
What can be done Here?
Thanks
Hrishikesh


That's how it's done. Was anything selected when the form was submitted?
Is the select tag inside the form?
Sometimes a typo in HTML before the form can cause the form to not submit correctly. If you don't find it, post the HTML.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to read from a drop down in Servlet
 
Similar Threads
extracting some elements from ArrayList on JSP
Possible suspects ?
dynamic drop down list
Handle Ajax call with Neutralization returning XML
Dropdown Selected returning unexpected value on submit.