Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

drop down list doPost() servlet

 
Sakai Bah
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone assist me HOW to invoke drop down menu list in doPost() servlet?
Upon selecting and clicking a submit button, the doPost will be invoked, and will appear.

Let say we have this code in eg;
===============================================================================================

index.jsp


Feedback.java

===============================================================================================

I tried using reqest.getParameters but it gives me null as displayed.
How can i have the selected value (Or even multiply values) still displayed?

Thanks and regards
Sakai
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65115
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to use code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.

You can go back and change your post to add code tags by clicking the button on your post.
 
Aditya Keyal
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You want to get the multiple values of the drop down if I gather rightly from your post. For that use request. getParameterValues() to get all the selected values. The return type of the getParameterValues() is a String array.
 
swapnl patil
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your drop down list is single select list or multiple select list ?
 
Mohammed Yousuff
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
below is what you expect




when multiple values are selected then HTML will send all the selected value with the same NAME, so you will get all the element which are selected...

Hope this may helped you ;)
 
Aditya Keyal
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One more small point that even I had overlooked. HTML and request parameters are case-sensitive. Your JSP reads Feedback whereas you are retrieving feedback. That is the reason why you are getting null value.

Other than that use the code mentioned above by Yousuf (with the case sensitive factor taken into consideration) and it should work.

 
Mohammed Yousuff
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thats right Aditya ;)
 
Sakai Bah
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys, I've sort it out.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic