Web tier: servlets, JSP, Web frameworks: Using GZIPOutputStream To Compress HTML
- Posted by: Jo V
- Posted on: October 14 2003 10:41 EDT
Thanks for taking time to look at my thread. I am trying to compress the HTML sent to the browser using the GZIPOutputStream class. Here is my JSP:
<%@ page import="com.picsoft.html.*,
GZIPOutputStream gzipStream = new GZIPOutputStream(response.getOutputStream());
<% gzipStream.write("Hello".getBytes()); %>
<% gzipStream.close(); %>
When I view the page on IE 6, it shows a blank page. When i remove the line
it shows the "Hello" string in a encoded way. What might be wrong? I am using weblogic as web server.
- Using GZIPOutputStream To Compress HTML by David Rabinowitz on October 15 2003 07:37 EDT
- HTTP compression, gzip by Sean Sullivan on October 23 2003 20:10 EDT
Are you trying to compress the entire HTML or just this string ? I think you should servlet for this. write just to the GZIPOutputStream and not to the response.getOutputSteram()
Thanks for the response David. Unfortunately our application uses JSPs and no servlets. So is there a way to compress the whole stream(not just a string) in JSP??
IMHO the best solution to compress the response is to use a filter servlet. You have to assign this filter in the deployment descriptor (web.xml) of your web application.
The interface for the filter can be found at:
If you have Apache, take a look at