My web.xml is similar, except I had "/app" as my servlet-name under 
filter-mapping, and i had no <dispatcher> tag.

Hmm, perhaps it's my filter itself then doing something in the wrong order? 
It's a very tiny chunk of code

public void doFilter(ServletRequest request, ServletResponse response, 
FilterChain chain) throws ServletException, IOException
  {
    HttpServletRequest req = (HttpServletRequest) request;
    HttpServletResponse res = (HttpServletResponse) response;
    
    if (!isGzipSupported(req))  // check headers to see if supported
    {
      // Invoke resource normally.
      chain.doFilter(req, res);
    }
    else
    {
      // Tell browser we are sending it gzipped data.
      res.setHeader("Content-Encoding", "gzip");
      
      // Invoke resource, accumulating output in the wrapper.
      ResponseWrapper responseWrapper = new ResponseWrapper(res);
      chain.doFilter(req, responseWrapper);
      
      // Get character array representing output.
      char[] responseChars = responseWrapper.toCharArray();
      
      // Make a writer that compresses data and puts
      // it into a byte array.
      ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
      GZIPOutputStream zipOut = new GZIPOutputStream(byteStream);
      OutputStreamWriter tempOut = new OutputStreamWriter(zipOut);
      
      // Compress original output and put it into byte array.
      tempOut.write(responseChars);
      
      // Gzip streams must be explicitly closed.
      tempOut.close();
      
      // Update the Content-Length header.
      res.setContentLength(byteStream.size());
      
      // Send compressed result to client.
      OutputStream realOut = res.getOutputStream();
      byteStream.writeTo(realOut);
    }
    
  }




-----Original Message-----
From: Paul Ferraro [mailto:[EMAIL PROTECTED]
Sent: Thursday, October 19, 2006 2:19 PM
To: Tapestry users
Subject: Re: [slight OT] GZip compression filter


Yes.  Since the filter applies http headers before the tapestry servlet
handles the request, you should be able to do this without issue.

How is your filter set up in your web.xml?

Here is mine (using pjl-comp-filter and servlet 2.4):
<filter>
  <filter-name>compress</filter-name>
<filter-class>com.planetj.servlet.filter.compression.CompressingFilter</filter-class>
  <!-- Adobe's plugin for IE chokes on gzip'ed PDFs -->
  <init-param>
    <param-name>excludeContentTypes</param-name>
    <param-value>application/pdf</param-value>
  </init-param>
  <init-param>
    <param-name>excludePathPatterns</param-name>
    <param-value>.*\.pdf</param-value>
  </init-param>
</filter>
<filter-mapping>
  <filter-name>compress</filter-name>
  <url-pattern>/*</url-pattern>
  <dispatcher>REQUEST</dispatcher>
</filter-mapping>

Paul

On Thu, 2006-10-19 at 13:45 -0400, [EMAIL PROTECTED]
wrote:
> Has anyone gotten a compression filter to work with Tap4? I guess since Tap4 
> has a single servlet, and uses lots of redirects or something, I always get 
> "Response already committed" for all my pages.
> 
> Thanks,
> Greg
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to