简体   繁体   中英

Java (jsp) redirect with HTTP POST data?

I have a system that allows guest logins via a guest account. I cannot modify the source code of the system, but I can add my own JSP files. I am implementing an anti-phishing login process and don't want to expose the real login URL in my HTML. Instead of creating a "guest" link that posts directly to the real login URL, I would like to forward the user to my own JSP that redirects their request to the real login.

This means I need to send POST data do the real login script in my redirect. If possible, I do not want to use the HttpClient class to open a connection and do the posting. The system does several redirects of its own after posting to the login script. Which means I would have to handle them myself if I used HttpClient.

So, is it possible to do a response.sendRedirect() and include POST data to the redirect URL?

Just forward the complete request to the other controller (servlet/JSP) and let the other controller process and respond.

From the Java Docs :

 forward(ServletRequest request, ServletResponse response) throws ServletException, IOException

Forwards a request from a servlet to another resource (servlet, JSP file, or HTML file) on the server. This method allows one servlet to do preliminary processing of a request and another resource to generate the response.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM