File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Java Interview Guide this week in the Jobs Discussion 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: 33132

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]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, 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: 2415
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,

I agree. Here's the link:
subject: load-on-startup for filter
It's not a secret anymore!