Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
4.3 HTTP 1.1 Request Headers
99
can examine the
Accept
header to decide which format to use. For exam
ple, images in PNG format have some compression advantages over those
in GIF, but only a few browsers support PNG. If you had images in both
formats, a servlet could call
request.getHeader("Accept")
, check for
image/png
, and if it finds it, use
xxx.png
filenames in all the
IMG
ele
ments it generates. Otherwise it would just use
xxx.gif
.
See Table 7.1 in Section 7.2 (HTTP 1.1 Response Headers and Their
Meaning) for the names and meanings of the common MIME types.
Accept Charset
This header indicates the character sets (e.g., ISO 8859 1) the browser
can use.
Accept Encoding
This header designates the types of encodings that the client knows how
to handle. If it receives this header, the server is free to encode the page
by using the format specified (usually to reduce transmission time),
sending the
Content Encoding
response header to indicate that it has
done so. This encoding type is completely distinct from the MIME type
of the actual document (as specified in the
Content Type
response
header), since this encoding is reversed before the browser decides what
to do with the content. On the other hand, using an encoding the
browser doesn't understand results in totally incomprehensible pages.
Consequently, it is critical that you explicitly check the
Accept Encod
ing
header before using any type of content encoding. Values of
gzip
or
compress
are the two standard possibilities.
Compressing pages before returning them is a very valuable service
because the decoding time is likely to be small compared to the savings
in transmission time. See Section 4.4 (Sending Compressed Web
Pages) for an example where compression reduces download times by
a factor of 10.
Accept Language
This header specifies the client's preferred languages, in case the servlet
can produce results in more than one language. The value of the header
should be one of the standard language codes such as
en
,
en us
,
da
,
etc. See RFC 1766 for details.
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