tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: enabling/disabling a servlet filter conditionally
Date Sun, 03 Aug 2008 00:41:36 GMT
Hash: SHA1


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


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

Do you have the ability to alter the configuration? I have another idea...

Take Filter B completely out of the configuration for the webapp and
install Filter D in its place.

Filter D is a newly-written filter you write that does nothing but
dispatch to a private instance of Filter B after checking the
appropriate conditional that you set up (and probably note in the
request attributes).

If you want, you can fake the FilterChain object so that doFilter does
nothing and then do the dispatch back to the FilterChain after
FilterB.doFilter returns, or you can just let FilterB.doFilter call back
into the filter chain itself. I think that should work.

This strategy allows you to accomplish your goal with a minimum of effort.

- -chris

Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla -


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

View raw message