Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
100
Chapter 4 Handling the Client Request: HTTP Request Headers
Authorization
This header is used by clients to identify themselves when accessing
password protected Web pages. See Section 4.5 (Restricting Access to
Web Pages) for an example.
Cache Control
This header can be used by the client to specify a number of options for
how pages should be cached by proxy servers. The request header is
usually ignored by servlets, but the
Cache Control
response header
can be valuable to indicate that a page is constantly changing and
shouldn't be cached. See Chapter 7 (Generating the Server Response:
HTTP Response Headers) for details.
Connection
This header tells whether or not the client can handle persistent HTTP
connections. These let the client or other browser retrieve multiple files
(e.g., an HTML file and several associated images) with a single socket
connection, saving the overhead of negotiating several independent
connections. With an HTTP 1.1 request, persistent connections are the
default, and the client must specify a value of
close
for this header to
use old style connections. In HTTP 1.0, a value of
keep alive
means
that persistent connections should be used.
Each HTTP request results in a new invocation of a servlet, regardless
of whether the request is a separate connection. That is, the server
invokes the servlet only after the server has already read the HTTP
request. This means that servlets need help from the server to handle
persistent connections. Consequently, the servlet's job is just to make it
possible for the server to use persistent connections, which is done by
sending a
Content Length
response header. Section 7.4 (Using Per
sistent HTTP Connections) has a detailed example.
Content Length
This header is only applicable to
POST
requests and gives the size of the
POST
data in bytes. Rather than calling
request.getIntHeader("Con
tent Length")
, you can simply use
request.getContentLength()
.
However, since servlets take care of reading the form data for you (see
Chapter 3, Handling the Client Request: Form Data ), you are
unlikely to use this header explicitly.
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
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