Servlet or JSP - How do I redirect a post request without data loss

做~自己de王妃 提交于 2019-12-31 06:08:26

问题


My server moved to a new location and I need to redirect requests to the new location. If I use HttpServletResponse.sendRedirect(new_server_location), I am losing all the POST data coming along with the original request. Is it possible to redirect to the new location without losing any of the POST data? The POST data can contain sensitive information like passwords. So making a GET request on the new server location is NOT an option.

Thanks in advance for the responses.


回答1:


The sendRedirect() is by default a HTTP 302 redirect. You want to send a HTTP 307 redirect instead.

response.setStatus(307);
response.setHeader("Location", new_server_location);

This only issues a default browser warning on most browsers.



来源:https://stackoverflow.com/questions/6449894/servlet-or-jsp-how-do-i-redirect-a-post-request-without-data-loss

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!