tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From C├ęcile QUERAN <cecile.que...@free.fr>
Subject GZIP, JSP and servlet
Date Wed, 02 May 2001 05:14:35 GMT
Is there a way to gzip the output of a JSP ?

Based on the HTTP Accept-Encoding header field, I open a GZIPOutputStream if
supported by the client browser, and I send the response.getOutputStream in
it. This is within a servlet.

When I just write directly in the GZIPOutputStream, it works fine.

When I try to include a JSP's content (with the include method of the
RequestDispatcher), a problem arises : the first out.write in the service
method of my compiled JSP throws an IllegalStateException "OutputStream
already in use".

Apparently, this comes from the HttpResponseAdapter which has two parameters
to indicate whether "out" is a PrintWriter or an OutputStream. My initial
response.getOutputStream sets the useStream field to true while the JSP
framework tries to instantiate a PrintWriter. (the problem is at least on
Tomcat 3.1)

I know I can rewrite my JSP as a servlet, which would solve the problem, but
for maintenance purpose, I 'd rather keep a JSP (in fact, it includes many
other JSPs, leading to 81 kBytes, hence the need for compression).

Thanks in advance.

                            L. QUERAN



Mime
View raw message