一个GZIP编码输出问题

avaj 08-01-18

如下代码为什么什么都显示不出来呢,应该能打印出hello world的啊,但是显示却是 雪白一边,这里假设浏览器支持gzip编码的,所以许多条件判断就省去了,希望哪位达人能指点迷津啊,代码如下
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException
{
response.setContentType("text/html");
OutputStream out = null;
response.setHeader("Content-Encoding", "GZIP");
out=new GZIPOutputStream(response.getOutputStream());
String content="hello world";
PrintWriter pw = new PrintWriter(out);
pw.println(content);
pw.flush();
}
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException
{
doGet(request,response);
}

banq
2008-01-21 16:43

Tomcat等容器已经提供gzip等压缩插件功能,只要配置一下就可以了。

avaj
2008-01-23 11:09

heihei,搞定了,大师就是大师啊