File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes sendRedirect method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "sendRedirect method" Watch "sendRedirect method" New topic

sendRedirect method

Derek Nahabedian

Joined: Jun 21, 2011
Posts: 3

I understand when a sendRedirect is executed, a 301 or 302 response is sent to the client, along with the desired URL. The browser then issues a new request for the desired URL.

My question is what HTTP method is generated under the hood? Get or Post?
Can a Get / Post be specified?

Thank you
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

The browser will generate a new Get request in response to your 300-sequence response. You don't have any choice about that.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63844

And thank goodness. It's what enables the P-R-G pattern!

[Asking smart questions] [About Bear] [Books by Bear]
Derek Nahabedian

Joined: Jun 21, 2011
Posts: 3

Thank you both - I am reading up on the PRG pattern.
I agree. Here's the link:
subject: sendRedirect method
It's not a secret anymore!