I’ve got a JSP redirecting to a URL backed by a servlet just fine – for example, with
<jsp:forward page="/myservlet"/>
but I’d like to switch the method from the incoming GET to a POST against the servlet URL.
How can I do that?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t. The incoming request has to be a POST as well. Just execute the desired job in the
doGet()method.Please note that
<jsp:forward>doesn’t do a redirect. A redirect is basically a 3nn response with aLocationheader pointing to the new URL on which the browser has to invoke a new GET request (which get reflected in browser address bar as well). Theresponse.sendRedirect()does that with a 302 response. A forward takes place fully internally in the server side, without changing the request URL.