Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
130
Chapter 6 Generating the Server Response: HTTP Status Codes
tracking is discussed in Chapter 9, and it is a good idea to use 
enco 
deURL
 routinely so that you can add session tracking at a later time with 
minimal changes to the code.
Core Approach
If you redirect users to a page within your site, plan ahead for session 
tracking by using 
response.sendRedirect(response.encodeURL(url))
, 
rather than just 
response.sendRedirect(url)
.
This status code is sometimes used interchangeably with 301. For exam 
ple, if you erroneously ask for 
http://host/~user
 (missing the trailing 
slash), some servers will reply with a 301 code while others will use 302. 
Technically, browsers are only supposed to automatically follow the 
redirection if the original request was 
GET
. For details, see the discus 
sion of the 307 status code. 
303 (See Other)
The 303 (
SC_SEE_OTHER
) status is similar to 301 and 302, except that 
if the original request was 
POST
, the new document (given in the 
Location
 header) should be retrieved with 
GET
. This code is new in 
HTTP 1.1. 
304 (Not Modified)
When a client has a cached document, it can perform a conditional 
request by supplying an 
If Modified Since
 header to indicate that it 
only wants the document if it has been changed since the specified date. 
A value of 304 (
SC_NOT_MODIFIED
) means that the cached version is 
up to date and the client should use it. Otherwise, the server should 
return the requested document with the normal (200) status code. Serv 
lets normally should not set this status code directly. Instead, they 
should implement the 
getLastModified
 method and let the default 
service
 method handle conditional requests based upon this modifica 
tion date. An example of this approach is given in Section 2.8 (An Exam 
ple Using Servlet Initialization and Page Modification Dates).
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

jsp web hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Jsp Web Hosting Cheapest Web Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved