Common HTTP 1.1 Request
Headers (Continued)
Connection
In HTTP 1.0, keep alive means browser can handle
persistent connection. In HTTP 1.1, persistent connection
is default. Persistent connections mean that the server can
reuse the same socket over again for requests very close
together from the same client
Servlets can t do this unilaterally; the best they can do is
to give the server enough info to permit persistent
connections. So, they should set Content Length with
setContentLength (using ByteArrayOutputStream to
determine length of output). See example in Core Servlets
and JavaServer Pages.
Cookie
Gives cookies previously sent to client. Use getCookies,
not getHeader. (See later slides)
41
Servlets
www.corewebprogramming.com
Common HTTP 1.1 Request
Headers (Continued)
Host
Indicates host given in original URL
This is a required header in HTTP 1.1. This fact is
important to know if you write a custom HTTP client
(e.g., WebClient used in book) or telnet to a server and
use the HTTP/1.1 version
If Modified Since
Indicates client wants page only if it has been changed
after specified date
Don't handle this situation directly; implement
getLastModified instead. See example in Core Servlets
and JavaServer Pages Chapter 2
42
Servlets
www.corewebprogramming.com
21