I had problem using Jayson Falkner's HTTP Compression Filter ("Servlets and JavaServer pages; the
J2EE Web Tier",
http://www.jspbook.com by Jayson Falkner), as it returned warning as response is already committed when app server does a server-side forward and tries to apply the filter a second time. I was using WSAD5.1.1 and
Struts 1.1. However, the behaviors is the same outside of Struts environment (meaning, while not using Struts) under WSAD 5.1.1.
I got it solved by using Sean Owne's Compression Filter (
http://sourceforge.net/projects/pjl-comp-filter/) with /* as url-pattern.
Comments from Sean Owen:
Re: Problem with *.do in Filters using Struts
Topic: Struts
Sean Owen, Nov 8, 2004 [replies:2]
"/*" is right. I think you are running into a bug in GZipFilter. I don't believe it works when the app server does a server-side forward and tries to apply the filter a second time. The recompression totally messes up the response. If I may plug my own work... I created an open-source compression filter that does not have this bug. It's also cleaner, faster and more full-featured than this old GZipFilter that people seem to use. Give it a try, along with a setting of "/*", and see if that solves your problem. PJL Compressing Filter
http://sourceforge.net/projects/pjl-comp-filter/ Additional comments from me:
I am now using Sean Owen's Filter, instead of Jayson Falkner's filter. My filter mapping is:
<filter-mapping> <filter-name>CompressingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
It works fine without throwing any Exception within Struts framework.
However, if I use /*.do, or /*.jsp, or /*.htm, it does not invoke the filter. It invokes the filter (obviously, for every page) only with /* url-pattern.
Question to Sean: Do you know why?
My
Servlet does redirection to another
JSP and Sean's filter is working fine within my Struts environment.
Comment to Sean: You have many assert statements like: assert config != null; You might consider removing those lines from published code. Otherwise, users have to comment those lines for the code to compile.