This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Loading common web objects on startup" Watch "Loading common web objects on startup" New topic
Author

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
Marshal

Joined: Jan 10, 2002
Posts: 60811
    
  65

Explore the concept of the context listener.


[Asking smart questions] [Bear's FrontMan] [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!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Loading common web objects on startup
 
Similar Threads
Loading Servlet On Startup
javaranch - Mock exam
How to deal with configuration data in a (web) application?
Storing images and css in a database
bundle, in one config file, web parameter names?