tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier ...@ice-sa.com>
Subject enabling/disabling a servlet filter conditionally
Date Fri, 01 Aug 2008 20:39:59 GMT
Hi.

Can one dynamically disable a servlet filter under some conditions, from 
within another preceding filter ?

In other words, suppose I have a servlet configured approximately like 
this :

<webapp>
<filter>
   <filter-name>filterA</filter>
      ... filterA parameters ...
</filter>
<filter-mapping>
     <filter-name>filterA</filter-name>
     <servlet-name>servletX</servlet-name>
</filter-mapping>
<filter>
   <filter-name>filterB</filter>
      ... filterB parameters ...
</filter>
<filter-mapping>
     <filter-name>filterB</filter-name>
     <servlet-name>servletX</servlet-name>
</filter-mapping>
<servlet>
   <servlet-name>servletX</servlet-name>
     ... servlet parameters ...
</servlet>
<servlet-mapping>
     <servlet-name>servletX</servlet-name>
     <url-pattern>*.xyz</url-pattern>
</servlet-mapping>
</webapp>

And suppose that I control the code of filter A but have no access to 
the code of filter B, and filter B has no parameter allowing to make it 
conditional.

Can I, from within filter A, which gets to see the request first, based 
on some characteristic of the request, decide that for this request I 
want to disable (or short-circuit or bypass) filter B ?
And if yes, could you point me in the right direction/documentation 
about how to do this ?
I can write simple filters and simple servlets, but am not really an 
habitual Java programmer.

Thanks in advance,
André

P.S. While we are at it,
- would the same apply if I had a third filter C ? Could I, in filter A, 
decide to disable filter B or filter C or both ?
- and/or, suppose that for filter C I would also have access to the 
code, could I design some mechanism whereby filter A could "tell" filter 
C not to do anything for this request ?

---------------------------------------------------------------------
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