SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 284 | Next

Larry Brown, Marty Hall, and Yaakov Chaikin

"Core Servlets and JavaServer Pages, Volume 2"




5.11 Example: A Compression Filter 245
5.11 Example: A Compression Filter
Most recent browsers can handle gzipped content, automatically uncompressing
documents that have gzip as the value of the Content-Encoding response
header and then treating the result as though it were the original document. Sending
such compressed content can be a real time saver because the time required to compress
the document on the server and then uncompress it on the client is typically
dwarfed by the savings in download time, especially when dial-up connections are
used. For example, Listing 5.22 shows a servlet that has very long, repetitive,
plain-text output: a ripe candidate for compression. If gzip could be applied, it could
compress the output by a factor of over 300!
However, although most browsers support this type of encoding, a few do not.
Sending compressed content to browsers that don??™t support gzip encoding produces
a totally garbled result. Browsers that support content encoding include most versions
of Netscape for UNIX, most versions of Internet Explorer for Windows,
Netscape 4.7 and later for Windows, Firefox, and Opera 5.12 and above. Therefore,
this compression cannot be done blindly??”it is only valid for clients that use the
Accept-Encoding request header to specify that they support gzip.
We demonstrate very similar functionality in Core Servlets and JavasServer Pages,
Volume 1: Core Technologies, compressing the output right in the servlet.


Pages:
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296