PrintWriter out = new PrintWriter(new GZIPOutputStream(out1),false);不理解是什么意思。
我的系统是xp+jdk1。3。1+tomcat4.1.3
我下面的程序是servlet一个压缩程序
在Tomcat上运行不出结果,但并不显示任何错误。就是不能把页面返回到客户端。
请大家帮忙看看
import java.io.*;
import java.util.zip.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ddd extends HttpServlet
{
public void doGet(HttpServletRequest req,HttpServletResponse res)
throws IOException,ServletException
{
res.setContentType("text/html");
PrintWriter out;
String title;
String headvalue = req.getHeader("Accept-Encoding");
title = "gzip";
OutputStream out1 = res.getOutputStream();
out = new PrintWriter(new GZIPOutputStream(out1),false);
res.setHeader("Content-Encoding","gzip");
out.println("<html><title>"+title+"</title><body>");
String line ="Blah Clah Dlah Flah Glah Hlab"+
"wahaha, lehehe";
for(int i=0;i<10000;i++)
{
out.println(line);
}
out.println("</body></html>");
}
}