tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: enabling/disabling a servlet filter conditionally
Date Sun, 03 Aug 2008 00:41:36 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

André,

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 :

[snip]

| 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

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkiU/sAACgkQ9CaO5/Lv0PBd7wCdHD7mNKNVZEzYoAetpfmMhLKL
0C0An3AIAgGwJ7ORINj1loN5KikQ21uH
=r5iP
-----END PGP SIGNATURE-----

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