This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
hi... all I m indulge in a project in which I have saved some values in servlet context that would be work for all user. and these values are picked from database.Servlet which save these values in servlet context, is loaded when server gets start. my problem is that if any time I change the values in database then I 'll have to restart the server agin. how can avoid this. I m using tomcat 4.1 /oracle/wion 2000 please give me a suggession
That's a basic cache problem - every time the backing store is updated, the cache needs to be invalidated. Maybe your code that changes the values can access a special URL in your web app that tells it to update its cache.
Joined: Jul 24, 2003
thanks for it. but my problem is that if there is any updation in database then the value saved in servlet context should get updated.If I restart the the server. then the servlet loaded agin with the updated values , but I want that without restarting the server servlet context should get updated. thanks
If your servlet saves the values in the context upon startup (using getServletContext().setAttribute() I'm assuming), why not do the same whenever the data changes?
Joined: Dec 13, 2004
^ note that this will not work if your application is distributed, since you'll have seperate ServletContexts.
Joined: Mar 22, 2005
but I want that without restarting the server servlet context should get updated.
That's why I suggested that the code that updates the value hits a special URL (in the same servlet context as your cache) that causes the value to be updated. If the change happens in code that's outside your control you may need to use a trigger on that DB table (although I wouldn't know how that could access a URL).