tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hassan Schroeder" <>
Subject Re: enabling/disabling a servlet filter conditionally
Date Fri, 01 Aug 2008 22:48:30 GMT
On Fri, Aug 1, 2008 at 3:30 PM, André Warnier <> wrote:

>> You could /probably/ -- untested conjecture -- break the FilterChain at
>> that point by forwarding to a URL for which Filter B wasn't applied (or
>> was applied only to a REQUEST rather than FORWARD.
> On second read, can you elaborate on that one ?
> Do I understand correctly, as follows ?

> b) make filter A, in case it doesn't want filter B to run, change the
> request URL to, e.g., "",

yes, with the caveat that "change the request URL" means use  a
RequestDispatcher to forward the request.

The second approach which might be less obtrusive, means to define
your Filters so that Filter B is only applied to REQUESTs, e.g.


When Filter A sees the condition where Filter B should not be
applied, it forwards the request to the original request URL; now
Filter B is not part of the FilterChain because it's not a REQUEST.
Actually, you could probably do the same with Filter A, since you
presumably wouldn't need it to act on the request a second time.

Again, untested, but easy enough to try, and you don't need to make
any filename/URL-pattern changes as with the first approach.

Hassan Schroeder ------------------------

To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message