This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft 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 Java 8 in Action this week in the Java 8 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: 60074
    
  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!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Loading common web objects on startup
 
Similar Threads
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?
javaranch - Mock exam
Loading Servlet On Startup