tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Barker" <wbar...@wilshire.com>
Subject Re: How can I exclude in <url-pattern> for filters in Tomcat 5.5.20?
Date Tue, 04 Dec 2007 04:07:04 GMT
You can't do it from the config alone (the spec doesn't have exclude 
mappings).  You would need to do it from within your Filter code, e.g.:

public class RewriteFilter implements Filter {
     public void init(FilterConfig conf) {
         // init logic here
     }
     public void destroy() {
        // release resources here
     }
     public void doFilter(ServletRequest req, ServletResponse res, 
FilterChain chain)
     throws ServletException, IOException {
          if(forMe(req)) {
              // business logic here
          }
          chain.doFilter(req, res);
     }
     private boolean forMe(ServletRequest req) {
         if(req instanceof HttpServletRequest) {
             HttpServletRequest hreq = (HttpServletRequest)req;
             return ! hreq.getRequestURI().endsWith(".earth");
         }
         return true;
    }
}

"kkus" <kk_us@hotmail.com> wrote in message 
news:14133848.post@talk.nabble.com...
>
> Hi,
>
> For the following setting in web.xml, if I have a request like /*.earth 
> how
> can I exclude it from these filters? I don't want to filters to handle
> request from /*.earth. Thanks!
>
> <filter-mapping>
>        <filter-name>rewriteFilter</filter-name>
>        <url-pattern>/*</url-pattern>
>    </filter-mapping>
>    <filter-mapping>
>        <filter-name>sitemesh</filter-name>
>        <url-pattern>/*</url-pattern>
>    </filter-mapping>
> -- 
> View this message in context: 
> http://www.nabble.com/How-can-I-exclude-in-%3Curl-pattern%3E-for-filters-in-Tomcat-5.5.20--tf4937775.html#a14133848
> Sent from the Tomcat - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
> 




---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message