aspose file tools*
The moose likes Servlets and the fly likes Possible to change status code sent by response.sendRedirect Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Possible to change status code sent by response.sendRedirect" Watch "Possible to change status code sent by response.sendRedirect" New topic
Author

Possible to change status code sent by response.sendRedirect

Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436
Hi,

I'm using Tomcat 6.0.26 (Java 1.6). By default, the "response.sendRedirect" method sends a 302 (Moved Temporarily) status code to the client. Is it possible to set the default behavior to have this command send a "301" (Moved Permanently) instead, or do I just need to avoid using response.sendRedirect altogether?

Thanks, - Dave
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61760
    
  67

No "by default" about it. That's what a redirect is. If you don't want a redirect, don't use sendRedirect(). You can set the response headers as you wish using the other methods.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61760
    
  67

Not Tomcat-specific, so moved to the Servlets forum.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Possible to change status code sent by response.sendRedirect