aspose file tools*
The moose likes Tomcat and the fly likes Can two filters use the same filter-class? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Can two filters use the same filter-class?" Watch "Can two filters use the same filter-class?" New topic
Author

Can two filters use the same filter-class?

David Coons
Greenhorn

Joined: Feb 07, 2011
Posts: 6

I've added a <filter> and a <filter-mapping> to web.xml that turns a functioning Tomcat 6.0 system into one with severe startup errors in catalina.log. My first thought is that the errors are caused by the new filter using the same filter-class as an existing filter (since the other additions are just params). Are two filters with the same filter-class permissible in Tomcat?

The filter class that's used twice handles single-sign-on. All the current pages are behind SSO. I've added a JSP page that requests user input before redirecting to the app's normal startup page, and it needs to be behind SSO as well. The two filters are necessary (as far as I know) because the url-patterns are different.

Here's the portion of catalina.log that's generated when Tomcat starts:
Tim McGuire
Ranch Hand

Joined: Apr 30, 2003
Posts: 820

The short answer is yes, two filters can use the same filter class. you have deeper problems and you should start by posting the code of the filter in question.
You said,
The two filters are necessary (as far as I know) because the url-patterns are different.


it won't help your underlying problem, but you could make two filter-mappings that use the same filter instead of two filters. Each of the filter-mappings would have a different url-pattern, but the filter-name would be the same.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16145
    
  21

Two filters are not a problem. However, reading between the lines, it looks like you have other issues:

1. Apparently you included a MS SQL server driver jar in your WAR. You shouldn't do that.

2. It also looks like you have some sort of cron services such as the Quartz scheduler in your webapp. That's fine, but you need to shut it down when the webapp terminates.

Oh:

3. Welcome to the JavaRanch!


Customer surveys are for companies who didn't pay proper attention to begin with.
David Coons
Greenhorn

Joined: Feb 07, 2011
Posts: 6

Thanks, Tim[0] and Tim[1] (you can arm-wrestle for the title of Tim[0]). This site is a goldmine for beginners. Thanks for the info about filters.

Late one night last week as I was thinking about this task, having worked on it for several days, I decided I was going about it the wrong way and created a separate webapp. It's easier than having to fit my code around someone else's.

Is oracle.jdbc.driver.OracleDriver or servletapi-2.4-20040521.jar the MS SQL driver?
 
 
subject: Can two filters use the same filter-class?