You can certainly do compression by setting the response header and using the
gzip output stream, writing into a buffer.  We did this and it worked well up to
a point.  Some pages in combination with certain versions of the browsers
resulted in the web browser hanging or crashing, and for Netscape we had great
difficulty printing any pages that came back compressed.  I don't know if there
was a solution to these problems but we dropped it.  Make sure you test it
thoroughly.

The additional load on the webserver was surprisingly small, maybe 15%.  There
was no noticeable difference in response of the web browser.

Bill








Heiko Grussbach <[EMAIL PROTECTED]> on 08/09/99 02:36:07 AM

Please respond to "A mailing list for discussion about Sun Microsystem's Java
      Servlet API Technology." <[EMAIL PROTECTED]>








 To:      [EMAIL PROTECTED]

 cc:      (bcc: Bill Kayser/Worldstreet)



 Subject: Re: Compressing the output of a servlet









Hi Andr�s,

I havent used compression myself, but info may be found in J. Hunters
servlet book on page 189. According to this, you need to set the content
header of the response to x-gzip or x-compress (not just to gzip as you
do).
Also, revise your check for the the header, it might return null in which
case your first line would fail with a NullPointerException.
Please tell me if you get it working!!

Regards

Heiko
[EMAIL PROTECTED]





Andr�s Aguiar <[EMAIL PROTECTED]> on 07-08-99 11:53:47

Please respond to "A mailing list for discussion about Sun Microsystem's
      Java              Servlet API Technology."
      <[EMAIL PROTECTED]>

To:   [EMAIL PROTECTED]
cc:    (bcc: Heiko Grussbach/NMG/CRP-HT)

Subject:  Compressing the output of a servlet



Content-type: text/plain; charset

I'm trying to send the output of my servlet compressed to the browser,
depending on the 'Accept-Encoding' header in the HTTP request.
I've followed the HTTP1.1 spec, but it seems that I'm doing something
wrong.
This is the code I'm using:
//-----------------------------
// htmlOut is a StringBuffer that has the data to send to the browser.
if      (req.getHeader("Accept-Encoding").indexOf("gzip") >{
        res.setHeader("Content-Encoding", "gzip");
        res.setHeader("Transfer-Encoding","chunked");
        res.getOutputStream().write(new
String(Long.toHexString(htmlOut.length()).toUpperCase() +
"\r\n").getBytes());
        GZIPOutputStream gzOut GZIPOutputStream(res.getOutputStream());
        gzOut.write(htmlOut.toString().getBytes());
        gzOut.close();
        res.getOutputStream().write(new
String("\r\n0\r\n\r\n").getBytes());
        res.getOutputStream().close();
}
//---------------------
If someone was able to do it, send me a clue.
Regards.
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to