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
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.
No, a HTTP redirect will always use GET for the target page.
However, POST data are not much safer than GET data anyway. The user can still tamper with them. Store them in the session instead.
use javascript
$('#inset_form').html('<form action="FlowService" name="form" method="post" style="display:none;"><input type="hidden" name="idapp" value="' + idApp + '" /></form>');
document.forms['form'].submit();
Check out this once :
String url = "http://www.mysite/servlets/theServlet";
RequestDispatcher dispatcher = servletContext().getRequestDispatcher(url);
dispatcher.forward(request, response);
This is kinda old, but here I've succesfully run this:
response.setStatus(307); //this makes the redirection keep your requesting method as is.
response.addHeader("Location", "http://address.to/redirect");
See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.8 for explanation of HTTP 307 status code.
Use sendredirect without giving any parameters, and hide those parameters in a session-scoped servlet, and if you need those parameters in the redirected page, use them through this servlet.