If your pattern is /*.jsp, then your filter applies to all jsps.

-----Original Message-----
From: Mark [mailto:[EMAIL PROTECTED] 
Sent: October 22, 2004 1:19 AM
To: Tomcat Users List
Subject: RE: adding HTTP headers for all responses in web application


question: will the filter applied to response for custom error pages defined
in web.xml:
example:
<error-page>
  <exception-type>MyException</exception-type>
  <location>/errorPage.jsp</location>
</error-page>


--- "Shapira, Yoav" <[EMAIL PROTECTED]> wrote:

> 
> Hi,
> There are filters that ship with Tomcat's example webapp.  Beside 
> being the best how-to possible, there's actually one that does what 
> you want
> for character encoding, so it's a trivial copy/paste to suit it to
> whatever headers you need.
> 
> Yoav Shapira http://www.yoavshapira.com
> 
> 
> >-----Original Message-----
> >From: Steven J.Owens [mailto:[EMAIL PROTECTED]
> >Sent: Wednesday, October 20, 2004 10:10 PM
> >To: Tomcat Users List
> >Subject: Re: adding HTTP headers for all responses in web
> application
> >
> >On Wed, Oct 20, 2004 at 11:07:58AM -0400, Ben Souther wrote:
> >> Search the archives, I believe Tim Funk has actually written and 
> >> published one....  Not sure though.
> >
> >     It's pretty straight-forward.  This is the first filter I
> ever
> >coded, it was a snap.  I make no guarantees that the particular 
> >headers are exactly what you need (browser caching is annoyingly 
> >difficult to disable).
> >
>
>-config----------------------------------------------------------------
> ----
> >-
> >    <filter>
> >        <filter-name>NoCacheFilter</filter-name>
> >        <filter-class>class.path.to.NoCacheFilter</filter-class>
> >    </filter>
> >    <filter-mapping>
> >        <filter-name>NoCacheFilter</filter-name>
> >        <url-pattern>/*</url-pattern>
> >    </filter-mapping>
>
>-source----------------------------------------------------------------
> ----
> >-
> >import javax.servlet.Filter;
> >import javax.servlet.FilterChain;
> >import javax.servlet.FilterConfig;
> >import javax.servlet.ServletRequest;
> >import javax.servlet.ServletResponse;
> >import javax.servlet.http.HttpServletResponse;
> >import javax.servlet.http.HttpServletRequest;
> >import java.io.IOException;
> >import javax.servlet.ServletException;
> >
> >public class NoCacheFilter implements Filter {
> >
> >    public void init(FilterConfig config) throws ServletException
> {
> >        this.filterConfig = config;
> >    }
> >    private FilterConfig filterConfig;
> >    public FilterConfig getFilterConfig() {
> >        return this.filterConfig;
> >    }
> >    public void setFilterConfig (FilterConfig filterConfig) {
> >        this.filterConfig = filterConfig;
> >    }
> >    public void destroy() {
> >        this.filterConfig = null;
> >    }
> >
> >    public void doFilter (ServletRequest request,
> >                          ServletResponse response,
> >                          FilterChain chain) {
> >        try {
> >            if (response instanceof HttpServletResponse) {
> >                HttpServletResponse httpresponse = 
> >(HttpServletResponse)response ;
> >                // Set the Cache-Control and Expires header
> >                httpresponse.setHeader("Cache-Control",
> "no-cache") ;
> >                httpresponse.setHeader("Expires", "0") ;
> >            }
> >            chain.doFilter (request, response);
> >        } catch (IOException e) {
> >            System.out.println ("IOException in NoCacheFilter");
> >            e.printStackTrace() ;
> >        } catch (ServletException e) {
> >            System.out.println ("ServletException in
> NoCacheFilter");
> >            e.printStackTrace() ;
> >        }
> >    }
> >}
>
>----------------------------------------------------------------------
> >
> >--
> >Steven J. Owens
> >[EMAIL PROTECTED]
> >
> >"I'm going to make broad, sweeping generalizations and strong,  
> >declarative statements, because otherwise I'll be here all night
> and
> > this document will be four times longer and much less fun to
> read.
> > Take it all with a grain of salt." -
> http://darksleep.com/notablog
> >
> >
>
>---------------------------------------------------------------------
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail:
> [EMAIL PROTECTED]
> 
> 
> 
> 
> This e-mail, including any attachments, is a confidential business 
> communication, and may contain information that is confidential, 
> proprietary and/or privileged.  This e-mail is intended only for the 
> individual(s) to whom it is addressed, and may not be saved, copied, 
> printed, disclosed or used by anyone else.  If you are not
> the(an) intended recipient, please immediately delete this e-mail from 
> your computer system and notify the sender.  Thank you.
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 



                
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today! http://vote.yahoo.com

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


!DSPAM:4178984f42891229534975!

Reply via email to