Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

response code for sendRedirect

 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I like to know the response code for sendRedirect

I developed a sample application which redirects the request from a servlet to a jsp.

I used [mozdev.org] Live Http Headers and traced the response header for redirects. What I found was


HTTP/1.x 302 Moved Temporarily


But Head First book claims the response code redirects is "301"

I want to confirm this
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
301 is "Moved Permanently"
302 is "Moved Temporarily"

For more information:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html


With LiveHTTPHeaders, you're seeing exactly what the server is returning.
[ December 15, 2005: Message edited by: Ben Souther ]
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ben

Under what circumstances will the Container issue a 301 response (or) what should I do to send a 301 response header.
[ December 16, 2005: Message edited by: Vishnu Prakash ]
 
Bosun Bello
Ranch Hand
Posts: 1510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to send a 301, just use response.setStatus(response.SC_MOVED_PERMANENTLY)
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To add to Bosun's answer, you can see all of the response constants in the HttpServletResponse API:
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/http/HttpServletResponse.html
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for response Bosun and Ben.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic