I'm trying to compress a PDF Stream before transmitting to the client. The browser is 
not displaying anything. The PDF displays normally without my GZIP code. (I get 33% 
size reduction with compression)

Where have I goofed ? Thanks in Advance

Heres the Servlet Code

----------------------------------------------------------------------------------------------------------------------------------------

OutputStream sos = ServletUtilities.zipIt(request, response);
response.setHeader("Vary", "Accept-Encoding");
response.setContentType("application/pdf");

if (sos == null) {
        System.out.println("Null SOS");
}

try {   byte [] pdfStream = pdfUtil.getPDFDoc(afpStream, 0);
        System.out.println("Length = " + pdfStream.length);
        sos.write(pdfStream, 0, pdfStream.length);
    }
catch (Throwable theException) {
        theException.printStackTrace();
        }
finally {
        sos.close();
        }
----------------------------------------------------------------------

Here's the ServletUtilities code

----------------------------------------------------------------------

public static OutputStream zipIt(HttpServletRequest request,
                                HttpServletResponse response)
                           throws ServletException, IOException {
OutputStream out = response.getOutputStream();
String encodings = request.getHeader("Accept-Encoding");

   if (encodings != null && encodings.indexOf("gzip") != -1) {
        System.out.println("GZIP!!!");
        response.setHeader("Content-Encoding", "x-gzip");
        out = new GZIPOutputStream(out);
   }

   return out;
}

___________________________________________________________________________
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