In a J2EE application, how do I create a global Filter that can access other webapps installed on that app server?
5 Answers
In case anyone is still interested, here are my findings regarding this question:
For tomcat and others webapp servers derived from it (eg: JBoss), you can add your filter to the "global" web.xml, usually located under $TOMCAT_HOME/conf/web.xml.
For Websphere, I´ve found the following article to be useful: http://www-03.ibm.com/support/techdocs/atsmastr.nsf/WebIndex/WP101859 . In this case, the basic idea is that you write a ServletContext Listener and uses it to attach your filter to the app

- 974
- 12
- 18
The Servlet-API does not provide such a security leak. But some containers offer alike. Have a look at the <Valve>
Configuration of Apache Tomcat. Maybe there is a similar functionality for webshere, but typically you need to hire a ibm consultant to "find" the configuration.

- 20,046
- 8
- 53
- 94
Some application servers/servlet containers (Tomcat, JBoss) provide the cross context feature. It does depend on what you're running your application within however, it's not a J2EE feature.
http://tomcat.apache.org/tomcat-5.5-doc/config/context.html
I'm not sure whether this will help you in what you want to do. What is it exactly? : )
Take a look at this response as well:
What does the crossContext attribute do in Tomcat? Does it enable session sharing?

- 1
- 1

- 62,090
- 32
- 125
- 150
-
Like JBoss, Websphere also uses Tomcat under the hoods and if I recall my rusty Websphere experiences correctly, the very similar `crossContext` setting is just available at Websphere. This way you could create a webapp which runs on the ROOT and run the filter on `/*`. But again, that's the theory, I can't confirm this from own experience. Alternatively you could declare the filter in appserver's own `web.xml`. +1 for the hint regardless :) – BalusC Jan 20 '10 at 22:50
There is no way to do this in a container/platform independent way. Your J2EE container might provide hooks for you to do this though.

- 30,111
- 9
- 76
- 83
This worked for me: https://stackoverflow.com/a/8815211/964681
Sorry, couldn't just comment on your question. Haven't enough "points".

- 1
- 1

- 723
- 1
- 8
- 11