Generating the Server 
Response: HTTP Status Codes
Example HTTP 1.1 Response
HTTP/1.1 
200
OK
Content Type: text/html
...
Changing the status code lets you perform a 
number of tasks not otherwise possible
Forward client to another page
Indicate a missing resource
Instruct browser to use cached copy
Set status before sending document
49
Servlets
www.corewebprogramming.com
Setting Status Codes
public void setStatus(int statusCode) 
Use a constant for the code, not an explicit int.
Constants are in HttpServletResponse
Names derived from standard message.
E.g., SC_OK, SC_NOT_FOUND, etc.
public void sendError(int code, 
String message) 
Wraps message inside small HTML document
public void sendRedirect(String url) 
Relative URLs permitted in 2.2/2.3
Also sets Location header
50
Servlets
www.corewebprogramming.com
25




  

Home

About Services Network Support FAQ Order Contact
 

Servlet Web Hosting

Our partners:Jsp Web Hosting Unlimited Web Hosting Cheapest Web Hosting  Java Web Hosting Web Templates Best Web Templates PHP Mysql Web Hosting Interland Web Hosting Cheap Web Hosting PHP Web Hosting Tomcat Web Hosting Quality Web Hosting Best Web Hosting  Mac Web Hosting 

Lunarwebhost.net  Business web hosting division of Vision Web Hosting Inc. All rights reserved