package com.junmix.utilities.gzip; import java.io.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; public class GZIPResponseWrapper extends HttpServletResponseWrapper { protected HttpServletResponse origResponse = null; protected ServletOutputStream stream = null; protected PrintWriter writer = null; public GZIPResponseWrapper(HttpServletResponse response) { super(response); origResponse = response; } public ServletOutputStream createOutputStream() throws IOException { return (new GZIPResponseStream(origResponse)); } public void finishResponse() { try { if (writer != null) { writer.close(); } else { if (stream != null) { stream.close(); } } } catch (IOException e) { } } public void flushBuffer() throws IOException { stream.flush(); } public ServletOutputStream getOutputStream() throws IOException { if (writer != null) { throw new IllegalStateException("getWriter is already opened."); } if (stream == null) { stream = createOutputStream(); } return (stream); } public PrintWriter getWriter() throws IOException { if (writer != null) { return (writer); } if (stream != null) { throw new IllegalStateException("getOutputStream is already opened."); } stream = createOutputStream(); writer = new PrintWriter(new OutputStreamWriter(stream, "SJIS")); return (writer); } public void setContentLength(int length) { } }