Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to read from a drop down in Servlet

 
Hrishikesh Ghatnekar
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 256
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Neeraj Dheer
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic