struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject Re: Struts + Filter Chain = broken?
Date Sun, 28 Dec 2003 18:10:01 GMT
Quoting Oscar Picasso <oscgoogle@yahoo.com>:

> I have a problem using filter chain with Struts
> 
> I have wrote a simple filter to use in a servlet
> filter chain for postprocessing JSP output.
> 
> It works like this:
> 
> 1. Receive request, wrap response with its own
> response wrapper, and then pass it to filter chain.
> 
> 2. The filter own response wrapper stores content in
> its own buffer when any call is made to
> response.getOutputStream().write().
> 
> 3. When request returns from filter chain - get
> content from buffer, apply an xslt transformation &
> then flush the transformed content to the original
> response.getOutputStream().
> 
> This all works fine when I request directly a JSP
> page. 
> 
> However if the JSP page is request by a struts
> forward, when the request returns from the filter
> chain - the original
> response.getOutputStream().write() never prints
> anything to the browser.
> 

In a Servlet 2.3 environment (i.e. Tomcat 4.x), filters are only applied based
on the *original* request URI (the one that selects your Action), not on the
one use to forward to a JSP page.  In a Servlet 2.4 environment (i.e. Tomcat
5.x), you can also ask for the filter to be applied on request dispatcher
calls, but you have to make this explicit:

    <filter-mapping>
        <filter-name>MyFilter</filter-name>
        <url-pattern>myjsppage.jsp</url-pattern>
        <dispatcher>FORWARD</dispatcher>
    </filter-mapping>


> Any idea?

Craig McClanahan


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message