Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Loading common web objects on startup  RSS feed

 
Rusty Enisin
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66208
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Explore the concept of the context listener.
 
Dave Wingate
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another (older & inferior) strategy is to define a servlet that loads on startup and initializes system-wide objects.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!