I have a HttpServlet (HelloWorld) with doGet and doPost method. But both behave differently ( for example: doGet will print "Inside doGet HelloWorld" and doPost will print "Inside doPost HelloWorld"). Using RequestDispatcher if I want to call this two methods seperately. I think by default it will call the doGet method. To call the doPost method what should i have to do?
RequestDispatcher requestDispatcher = getServletContext().getRequestDispatcher("/HelloWorld");
Thanks & Regards,
Originally posted by William Brogden:
You are forwarding the entire request - the receiving servlet service method will look at the request to see if it is a GET or a POST. In order to change a request method, you have to change the request by wrapping it in a HttpServletRequestWrapper with a custom getMethod() that returns the method you want it to use.
Thanks Louis Saha & William Brogden.