permaculture playing cards*
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 Murach's Java Servlets and JSP this week in the Servlets 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: 60774
    
  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!
 
jQuery in Action, 2nd edition
 
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?