package was introduced in JDK 1.1. This package contains classes that
support reading and writing the
and ZIP compression formats. Although these classes were added to
support Java Archive (JAR) files, they also
provide a convenient, standard way for a servlet to send compressed
Compressed content doesn’t look any different to the end user because it’s decompressed by the browser before it’s displayed. Yet, while it looks the same, it can improve the end user’s experience by reducing the time required to download the content from the server. For heavily compressable content such as HTML, compression can reduce transmission times by an order of magnitude. Quite a trick! Just bear in mind that to compress content dynamically forces the server to perform extra work, so any speed-up in transmission time has to be weighed against slower server performance.
By now you should be familiar with the idea that a servlet can send a
Content-Type header as part of its response to
tell the client the type of information being returned. To send
compressed content, a servlet must also send a
header to tell the client the scheme by which the content has been
encoded. Under the HTTP 1.0 specification, the possible encoding
GZIP and ZIP compression formats, respectively.
Not all clients understand the
compress encodings. To tell the server which encoding schemes ...