This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes Servlets and the fly likes load-on-startup for filter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "load-on-startup for filter" Watch "load-on-startup for filter" New topic

load-on-startup for filter

Tapan Maru
Ranch Hand

Joined: May 08, 2006
Posts: 65
Why don't we have load-on-startup for Servlet filters as we have it for servlets?

Tapan Maru
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32312

My first thought was because filters aren't executed on their own and a servlet can run until all the relevant filters are loaded. THen I did an experiment and noticed that the filters are loaded on application startup. The servlets can be loaded on startup or on demand. In other words, you can't run anything until the filters are loaded so order doesn't matter.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Miku Ranjan
Ranch Hand

Joined: Oct 11, 2011
Posts: 98
Can you show your web.xml code here .
Tim Moores

Joined: Sep 21, 2011
Posts: 2409
Miku Ranjan wrote:Can you show your web.xml code here .

What good would that do?
Tapan Maru
Ranch Hand

Joined: May 08, 2006
Posts: 65
Hi Jeanne,

Thanks for the reply. Yes I have also verified that Filter's init method is called on application startup by the container so no need to have load-on-startup kind of tag for it.

Thanks for Helping,

Consider Paul's rocket mass heater.
subject: load-on-startup for filter
It's not a secret anymore!