File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Loading common web objects on startup Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Loading common web objects on startup" Watch "Loading common web objects on startup" New topic

Loading common web objects on startup

Rusty Enisin
Ranch Hand

Joined: May 26, 2005
Posts: 107
I have a bunch of common application-wide static data objects in my web application. I want to load them at startup so I don't waste time getting them from the data store each time I need them. The only way I know how to do this is with filters. In the filter check to see if the objects are loaded, if not load them as servlet context attributes.

I keep thinking there must be a way to put a class in the application context on startup so that the filter does not have to check on each request.

Any ideas?

The squeaky wheel gets the grease. Well, that or replaced...
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63839

Explore the concept of the context listener.

[Asking smart questions] [About Bear] [Books by Bear]
Dave Wingate
Ranch Hand

Joined: Mar 26, 2002
Posts: 262
Another (older & inferior) strategy is to define a servlet that loads on startup and initializes system-wide objects.

Fun programming etcetera!
I agree. Here's the link:
subject: Loading common web objects on startup
It's not a secret anymore!