• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Can two filters use the same filter-class?

 
Greenhorn
Posts: 6
Eclipse IDE Chrome Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
 
Ranch Hand
Posts: 820
IntelliJ IDE VI Editor Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Eclipse IDE Chrome Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
You'll never get away with this you overconfident blob! The most you will ever get is this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic