Common HTTP 1.1 Response
Headers
Cache Control (1.1) and Pragma (1.0)
A no cache value prevents browsers from caching page.
Send both headers or check HTTP version
Content Encoding
The way document is encoded. Browser reverses this
encoding before handling document. See compression
example earlier.
Content Length
The number of bytes in the response
See setContentLength on previous slide
Use ByteArrayOutputStream to buffer document so you
can determine size.
See detailed example in Core Servlets and
JavaServer Pages
61
Servlets
www.corewebprogramming.com
Common HTTP 1.1 Response
Headers (Continued)
Content Type
The MIME type of the document being returned.
Use setContentType to set this header
Expires
The time at which document should be considered out of
date and thus should no longer be cached
Use setDateHeader to set this header
Last Modified
The time document was last changed.
Don't set this header explicitly; provide a
getLastModified method instead.
See example in Core Servlets and JavaServer Pages
Chapter 2
62
Servlets
www.corewebprogramming.com
31