This week's giveaway is in the Spring forum.
We're giving away four copies of Microservices Testing (Live Project) and have Chris Love & Andres Sacco on-line!
See this thread for details.
Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
    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 ...
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

How pass the selected values of the Combo box to the servlet....

Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
In one of the Jsp page, i am having a combo box which will display the static data. Upon selecting the value from the drop down combo box and clicking on button, it will navigagte to the servlet and will display the selected value from the combo box.
Below are the codings for JSP and servlets. My problem here is, selected value of the combo box is not passing to the servlet.
Please tell me, where am i doing wrong and please give me the correct code. ( i am sure my JSP coding is not correct.)
I am not sure, whether this question belongs to Servlet forum or JSP forum, hence i am posting in both the places.
<form method=post action="http://localhost:8080/servlets/test/radio">

<select id='cmb'>
<input type=submit value="OK">
package test;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
public class radio extends HttpServlet{
public void init(ServletConfig sc) throws ServletException//, IOException
System.out.println("Into Init of test1");
public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException{
PrintWriter out=res.getWriter();
String str=req.getParameter("cmb");
out.println("You have selected "+str);
out.println("You have not selected any thing");
public void doGet(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException{
Thanks in Advance,
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
The value of the selected option will be passed back to the server.
If you don't specifically supply a value the browser will generate a sequence number for you (starting at 0 I think).

Would get you "SERVLET1" on doing

in the servlet.
Posts: 67650
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Please do not post the same question in multiple forums. It wastes people's time writing redundant answers.
Please continue any discussion here.
[ September 19, 2003: Message edited by: Bear Bibeault ]
    Bookmark Topic Watch Topic
  • New Topic