This is the code of my servlet:
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
String result = (String)request.getParameter("action");
switch (result)
{
case "init":
request.setAttribute("CountriesList", signUpBean.getContriesList());
String arg = "/signup.jsp";
RequestDispatcher dispatcher = this.getServletContext().getRequestDispatcher(arg);
dispatcher.forward(request, response);
break;
case "submit":
//Code to handle the request
break;
}
}
When I click on the link signup?action=init
the servlet is initialized receiving the countries list and passing it to the signup.jsp
page in order to show the list on a select form element. When I compile the signup form, I push the submit button which has action="signup?action=submit" in the way the servlet can handle the request. Do you know a more elegant way or correct way to do what I mean?