- RKerr -
Glassfish has now run with gzip compression off for 10 days with no
repetition of the blank page problem.
That left us with the problem of large output files, and consequent slow
browser page loads. To deal with this, we created a filter which wraps the
response object before passing it up the filter chain, and applies gzip
compression to the output of the filter chain before passing it back to the
client.
Here's some of the code, note that the output variable is a String holding
the output of the filter chain recovered from the wrapped response object,
and that GZIPOutputStream is java.util.zip.GZIPOutputStream:
// Check for the HTTP header that signifies GZIP support,
// and if so, compress the output and set the headers to
// indicate compression.
String ae = request.getHeader("accept-encoding");
if (ae != null && ae.indexOf("gzip") != -1) {
response.setHeader("Content-Encoding", "gzip");
GZIPOutputStream goz = new
GZIPOutputStream(response.getOutputStream());
goz.write(output.getBytes());
goz.close();
} else {
// Client does not accept GZIP. Write back content
// produced by filter chain without amendment here.
response.getOutputStream().write(output.getBytes());
}
response.getOutputStream().close();
--
[Message sent by forum member 'grahamrobbins']
View Post: http://forums.java.net/node/732938