开发者

Can I flip the HTTP Method from GET to POST in some form of JSP redirect?

开发者 https://www.devze.com 2023-04-03 16:12 出处:网络
I\'ve got a JSP redirecting to a URL backed by a servlet just fine - for example, with <jsp:forward page=\"/my开发者_C百科servlet\"/>

I've got a JSP redirecting to a URL backed by a servlet just fine - for example, with

<jsp:forward page="/my开发者_C百科servlet"/> 

but I'd like to switch the method from the incoming GET to a POST against the servlet URL.

How can I do that?


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 a Location header 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). The response.sendRedirect() does that with a 302 response. A forward takes place fully internally in the server side, without changing the request URL.

0

精彩评论

暂无评论...
验证码 换一张
取 消