9.11. Example: A Compression Filter

Several 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 dialup connections are used. For example, Listing 9.21 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 ...

Get More Servlets and JavaServer Pages™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.