Reputation: 987
just a short question - what method (e. g. GET, POST etc.) does sendRedirect use? Does it inherits it from request? And, if so, is it possible to change it to another? Thanks!
Upvotes: 2
Views: 2804
Reputation: 19712
This matter is a little messy, see spec https://www.rfc-editor.org/rfc/rfc7231#section-6.4
There are a bunch of redirect response codes - 300 301 302 303 307 308
. We can probably summarize the rules as the following:
to put it in a table ( "-" means the same method )
300 301 302 303 307 308
HEAD - - - - - -
GET - - - - - -
POST - GET GET GET - -
other - - - GET - -
Browsers usually won't auto follow a redirect to POST.
In practice, 303 is the most often used code for web applications.
Upvotes: 2
Reputation: 4883
sendRedirect sends a RESPONSE, not a REQUEST. And hence, has no METHOD.
It is up to the client, but it will normally do a GET or a HEAD request to the Location that you provide on the redirect.
Upvotes: 5