| 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
|
 |
 |
|
|
subject: How to read from a drop down in Servlet
|
|
|