Gzip is GNU ZIP, many browsers support this compressed format Content, need to add response.addhead ("Content-Encoding", "gzip"); however, some unsupported browsers have an error, need to check Request.getHeaders ("accept-encoding"); whether GIZP is included.
The process of compression processing is processed in the filter chain, which is described in Web.xml of its own application:
filter>
filter-mapping>
Here CompressionFilter is the class of the Filter interface, when implementing the DOFILTER method:
WrappedResponse = New CompressionServletResponseWrapper (httpservletResponse) response
Chain.dofilter (Request, WrappedRESPONSE);
In fact, using CompressionServletResponseWrapper to handle server-side response, we all know that the content of JSP display is generated by the OUT output in Response, then compressionServletResponseWrapper will complete the task under Gzip compression using the compressionServletResponseWrapper: compressionResponseSstream Stream = New compressionResponsestream (Response);
Pack OutputStream in CompressionResponsestream
GzipOutputStream GzipStream = New GzipOutputStream (Output);
Response.addheader ("Content-Encoding", "GZIP");
The specific code should also be found online.