Originally posted by suri jagadish:
hi all,
iam working on a web application where i have to load the properties file and use those porperties in the application both in servlets and the jsp . I want the properties file to be loaded(On start up) when the application is deployed and should be accesible to all sessions commonly.Can anybody suggest any method as far as possible.and also it should be sensitive to changes to the propeties file and should be reflected into the application.
thank u
regards
jagadish
As one of the programmers replied in previous threads.you can use ServletContextListener for reading the property from the application context and then loading that into the java.util.Properties and then setting this property in the ServletContext so that this becomes visible to the whole application.
Another way that also might have drawbacks..but for some of my previous applications I have used this.
I make a servlet and in the web.xml entry I load the servlet on start up of the application. In the init() method of the servlet i do all the stuffs like loading the property from the file and then setting this into the ServletContext .soon after this is done I call the destroy() of the servlet.
That puts an end to the life-cycle of the servlet and by this time it has done its job.
cheers!