This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Servlets and the fly likes ServletFilter not being called Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "ServletFilter not being called" Watch "ServletFilter not being called" New topic

ServletFilter not being called

Alex Ryan

Joined: Aug 12, 2009
Posts: 14
Could someone tell me what is wrong with the following web.xml entry?
I want my ServletFilter to be called for every HttpRequest of any servlet or any JSP page but it is definitely not getting called for servlets in one specific scenario ... when the HttpSession is dead.
When the HttpSession is alive it seems to work.
However, if I issue a request from a page on my browser that has been left sitting for a while it seems to bypass the filter and go directly to the servlet which causes my application to crash.

I am perplexed at how to solve this problem and would be very grateful if anyone who understands Tomcat could tell me how to FORCE tomcat to use the filter in all circumstances.

Charles 'King
Ranch Hand

Joined: Jul 05, 2009
Posts: 56

Please check your DD syntax.

replace this: <servlet-name>*</servlet-name>

with: <url-pattern>/*</url-pattern>
Alex Ryan

Joined: Aug 12, 2009
Posts: 14
Thanks very much Charles.
You were absolutely right.
This solved my problem.
VERY much appreciated.
Good karma to you.
I agree. Here's the link:
subject: ServletFilter not being called
It's not a secret anymore!