Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can two filters use the same filter-class?

 
David Coons
Greenhorn
Posts: 6
Chrome Eclipse IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18303
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
David Coons
Greenhorn
Posts: 6
Chrome Eclipse IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic