• Post Reply Bookmark Topic Watch Topic
  • New Topic

How would i capture client selection from a dropdown in servlet

 
john mattucci
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a servlet with a drop down list with 2 items. I would like to redirect the client to the appropriate page depending on his selection. I do not wish to use javascript. My question how would I capture the clients selection? And once I get his selection how would I direct it to the appropriate page.
I have the following-
out.println("Please select one of the following");
out.println("<SELECT NAME=\"Topic\">");
out.println("<OPTION SELECTED>Add/View/Modify Students");
out.println("<OPTION>Add/View/Modify Courses");
and also
RequestDispatcher dispatcher = null;
if(request.getParameter("Topic").equals("Add/View/Modify Students"))
{
dispatcher = getServletContext().getRequestDispatcher("/StudentServlet");
}
else
{
dispatcher = getServletContext().getRequestDispatcher("/CourseServlet");
}
dispatcher.forward(request, response);
Thank you all for your time
 
Praful Thakare
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
Just try out following changes
out.println("Please select one of the following");
out.println("<SELECT NAME=\"Topic\">");
out.println("<OPTION vlaue="S" SELECTED>Add/View/Modify Students");
out.println("<OPTION> value="C" Add/View/Modify Courses");
RequestDispatcher dispatcher = null;
if(request.getParameter("Topic").equals("S"))
{
dispatcher = getServletContext().getRequestDispatcher("/StudentServlet");
}
else
{
dispatcher = getServletContext().getRequestDispatcher("/CourseServlet");
}
dispatcher.forward(request, response);
hope this will help u
regards
...Praful
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!