André Warnier wrote:
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 ?

The only way I can think of doing so is to forward directly to the servlet, using a request dispatcher. Of course this only applies if the filter acts against a single servlet.

You might be able to use JMX to access Tomcat internals and turn it off, but there's no servlet API method or means to do this AFAIK.

p


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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




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

Reply via email to