• Post Reply Bookmark Topic Watch Topic
  • New Topic

Loading the Properties file in a Web Application  RSS feed

 
Sultan Khadar
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

is there any way to load the properties file only once in a web application at the startup
and use through out the application?

For example if app.properties is the properties file and if we want to load it
at the startup of the application and can made it available throughout the application without
reloading the file.

Please suggest.
Thanks.
Sulatan
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use a ServletContextListener.
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the kind of thing that application scope is good for. Application scope objects live for the life of the webapp or until explicitly destroyed and are shared by all users in the webapp.

You can either pre-construct them or load the properties on first reference, depending on your preference.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!