Hi All
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:
<html>
<body>
<%@ page import="com.picsoft.html.*,
javax.naming.*,
java.util.zip.*"
buffer="128kb"
%>
<%
response.setHeader("Content-Encoding", "gzip");
response.setContentType("text/html");
GZIPOutputStream gzipStream = new GZIPOutputStream(response.getOutputStream());
%>
<% gzipStream.write("Hello".getBytes()); %>
<% gzipStream.close(); %>
</body>
</html>
When I view the page on IE 6, it shows a blank page. When i remove the line
"response.setHeader("Content-Encoding", "gzip");"
it shows the "Hello" string in a encoded way. What might be wrong? I am using weblogic as web server.
Thanks
George
-
Using GZIPOutputStream To Compress HTML (4 messages)
- Posted by: Jo V
- Posted on: October 14 2003 10:41 EDT
Threaded Messages (4)
- Using GZIPOutputStream To Compress HTML by David Rabinowitz on October 15 2003 07:37 EDT
- Using GZIPOutputStream To Compress HTML by Jo V on October 15 2003 14:03 EDT
- Using GZIPOutputStream To Compress HTML by Wolfgang Gruber on October 23 2003 06:44 EDT
- Using GZIPOutputStream To Compress HTML by Jo V on October 15 2003 14:03 EDT
- HTTP compression, gzip by Sean Sullivan on October 23 2003 20:10 EDT
-
Using GZIPOutputStream To Compress HTML[ Go to top ]
- Posted by: David Rabinowitz
- Posted on: October 15 2003 07:37 EDT
- in response to Jo V
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()
David -
Using GZIPOutputStream To Compress HTML[ Go to top ]
- Posted by: Jo V
- Posted on: October 15 2003 14:03 EDT
- in response to David Rabinowitz
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??
George -
Using GZIPOutputStream To Compress HTML[ Go to top ]
- Posted by: Wolfgang Gruber
- Posted on: October 23 2003 18:44 EDT
- in response to Jo V
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:
Filter Interface -
HTTP compression, gzip[ Go to top ]
- Posted by: Sean Sullivan
- Posted on: October 23 2003 20:10 EDT
- in response to Jo V
If you have Apache, take a look at
http://httpd.apache.org/docs-2.0/en/mod/mod_deflate.html
http://sourceforge.net/projects/mod-gzip/
See also:
http://webreference.com/internet/software/servers/http/compression/