I have made a project in where three string parameters entered by user are sent to a servlet named controller. There I have used RequestDispatcher to forward those three parameters to a JSP page and print them. I have did something and made it work but am confused why it works only if I put all the commands in the service() method. I would love to know the right or the standard way of achieving this same result. And also I will be glad to know the actual work of doGet(),doPost() and service() and ProcessRequest() methods. This is the Servlet code:
public class controller extends HttpServlet {
public String TName,TUserName,TPassword;
@Override
public void service(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException{
TName = request.getParameter("name");
TUserName = request.getParameter("UserName");
TPassword = request.getParameter("Password");
RequestDispatcher rd =getServletContext().getRequestDispatcher("/welcome.jsp");
request.setAttribute("TName,TUserName,TPassword", rd);
rd.forward(request, response);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
}
}