• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

How to read from a drop down in Servlet

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Could you hold this kitten for a sec? I need to adjust this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic