Search code examples
jsphttp-redirectpostget

Can sendRedirect() act as a post method instead of get? - jsp/servlets


I have a simple form which accepts a username and a password. I have to use sendRedirect() method for the page to redirect to one page if log in is valid and to another if not. I need to use sendRedirect() and not forward() since the other pages are located in another server. I noticed that when using

response.sendRedirect(response.encodeRedirectURL("FileName.jsp?paramName=" +value));

the sendRedirect() is using the GET method since name=value are being shown in the URL. This is not desirable for me since I don't want these values to show in the URL for safety reasons.

Is there a way to POST these values using sendRedirect() ? I tried to do a form with method POST which hides the values I need but still no luck

What can I do please? Thanks :)


Solution

  • No, it's not possible. The only (dirty) workaround I see is to forward to an internal page containing a hidden form (with method POST) and a JavaScript script submitting this form.