tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject DO NOT REPLY [Bug 43191] compressableMimeType attribute ignored
Date Mon, 16 Jun 2008 12:44:44 GMT

Richard Mundell <> changed:

           What    |Removed                     |Added
                 CC|                            |

--- Comment #10 from Richard Mundell <>  2008-06-16 05:44:43
PST ---
I would like to share an alternative approach for this problem I just
implemented which avoids having to update Tomcat (or patch it).

Grab, and from the Tomcat source code distribution
(I did this with the 5.5.25 source).

Open up and modify the writetoGZip()
method. On line 305, replace...

    response.addHeader("Content-Encoding", "gzip");
    gzipstream = new GZIPOutputStream(output);


    if ((response.getContentType()!=null) &&
         (response.getContentType().equals("application/pdf")) {

        // I want to compress this content type
        response.addHeader("Content-Encoding", "gzip");
        gzipstream = new GZIPOutputStream(output);
    } else {
        // Don't want to compress this content type
        gzipstream = output;

Compile all three Java classes, then add the filter into your web.xml file:

        <filter-name>Compressing Filter</filter-name>
        <filter-name>Compressing Filter</filter-name>

This is very handy if you don't want to upgrade Tomcat, or for Tomcat 5.5.x
users for who there isn't an upgrade with the patch available yet. Also useful
if you don't want to compress server-wide for all of your web applications.


Configure bugmail:
------- You are receiving this mail because: -------
You are the assignee for the bug.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message