Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Loading common web objects on startup

 
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
Pie
Posts: 64683
86
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic