• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Property file is cached

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a web-interface to edit the property files. Through this JSP the user first selects a property file, I then display all the kesy for this file with checkboxes, user can select the key(s) and then change the values for these if he so wishes.
I am able to save the changes rightly to the property file. However when I select the same key for the same file again the old property shows up. I have to restart the application to get the changed property.
I have disallowed caching of my JSP. I religiously set all objects (including the property file objects) to null in the JSP everytime. How come the property file object is still being cached?
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Exactly where is the property file read the first time?
Do you create a Properties object with it?
How does the JSP know which properties file to write?
Bill
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'll add my own question as well:
How does the application know to reload the properties after you change them?
Typically a .properties file is read all-at-once into a java.util.Properties instance. If that loading sequence doesn't contain logic to reload when the file changes, the properties will never be updated.
 
Yash Sharma
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bill and David,
I am loading the Properties file using a static method of a custom class called PropertyLoader, this is an opensource code that I am using, which laods the file as Resource bundle as follows. I call this static method from my JSP to get the Properties file.

The files are located inside package hierarchy. In my JSP I get the Properties file object using this said static method. Once I am done using the Properties file I set it to null. I have also disabled caching of my JSP. Infact my single JSP does the following:
1. Displays a list of property files available (read from another property file), set this properties file obejct to null after populating the combolist.
2. When use select a file display below (frame like fashion, but actually done without using frames and in the same JSP using query strings) the properties with checkboxes; set this properties file object to null.
3. Display the form with editable values for chosen property, ; set this properties file object to null.
4. Submit this form to a servlet that modifies the property file, confirm changes and give a back-hyperlink to (1) page.
The property file names are passed as hidden form field. After I edit the file the changes are saved however the new property file is not loaded.
[ December 15, 2003: Message edited by: Yash Sharma ]
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am guessing that the ClassLoader is somehow caching the data. Is there some reason you are going through the bit with the ResourceBundle instead of reading a file?
Bill
 
Yash Sharma
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The main reason to go with loading the properties as ResourceBundle (or even other wise using the ClassLoader) is to avoid giving absolute paths. I worked as per the advice given here.
My properties file will be located inside a package structure (com.mypkg.myclasses) in WEB-INF/classes. When I try using the following code I get a FileNotFoundException (whether I prefix the package hierarchy or not). I am testing the app on Tomact as of now however the application would be hosted on Websphere finally and I don't want to specify to the user: put the Properties file inside bin or there or that. I want that my files should be where I want them to be.

Is there any way I can provide the absolute path, when loading using IO to avoid the classloader (without hardcoding it) to the PropertyLoader class?
[ December 15, 2003: Message edited by: Yash Sharma ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic