I am creating an application in whic开发者_开发知识库h we can edit the content. Now this change in content should be visible to all. I was using a static variable for that. With that the content changes and change is visible to all but after sometime it again initialize to its initial value.
So can you give any suggestion through which I can maintain the change without using the database?
With that the content changes and change is visible to all but after sometime it again initialize to its initial value'
It happens only when your ClasLoader reloads the class containing static property.
You can go for FILE-IO(.xml, .properties) or DB,
I guess you can use Application Context available in JSP (example: http://www.java2s.com/Code/Java/JSP/ApplicationObject.htm) or you can try to keep a singleton class which maintains application level data and instialise it from within the init method of any servlet that is marked for loading at startup of the server.
精彩评论