File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes filter across context Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "filter across context" Watch "filter across context" New topic

filter across context

Tom Henricksen
Ranch Hand

Joined: Mar 23, 2004
Posts: 136

Can you setup a filter to go across different context or at a server level? Or is there another mechanism that could do this in EE java?
Charles Lyons
Ranch Hand

Joined: Mar 27, 2003
Posts: 836
What's the specific reason?

If it's authentication you're after, using container authentication (if that's appropriate) will work across all containers in the same J2EE instance.

In general though, I think the answer is probably no. Please be a bit more specific, I'm intrigued...

Charles Lyons (SCJP 1.4, April 2003; SCJP 5, Dec 2006; SCWCD 1.4b, April 2004)
Author of OCEJWCD Study Companion for Oracle Exam 1Z0-899 (ISBN 0955160340 / Amazon Amazon UK )
steve souza
Ranch Hand

Joined: Jun 26, 2002
Posts: 862
I haven't tried it myself, but I have been told that tomcat has a web.xml file in the same directory as server.xml. When tomcat starts up it applies this file to all applications. If you put a servlet filter reference in this file and have any code that it executes in the server classpath then you should have to install the filter everywhere. Also, if the filter has some static reference then all apps would see the same data too, so you should be able to do pretty much what you want with these capabilities (assuming you use tomcat). - a fast, free open source performance tuning api.
JavaRanch Performance FAQ
I agree. Here's the link:
subject: filter across context
It's not a secret anymore!