aspose file tools
The moose likes Servlets and the fly likes ClassLoader's getResourceAsStream is caching the InputStream object Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "ClassLoader Watch "ClassLoader New topic
Author

ClassLoader's getResourceAsStream is caching the InputStream object

Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209
hi all,
am using tomcat4.0
I have a utility class which checks whether the xml stylesheets have changed and reloads it if that is the case.
This is a utility class and hence does not have access to the ServletContext.
so instead i use the ClassLoader which loads this class and call getResourceAsStream method on it.
I have a second servlet which triggers the update method on this utility class(which reads the stream back)
The utility class is a singleton.
So all the servlets share the same instance of the utility class.
I tried printing the content of the changed xsl stylesheet files and still i find that the content as read from the InputStream has not changed.
I dont know where it has cached the earlier stylesheet file
I checked the work directories and still not able to figure out how the eariler xsl got cached.
I do NOT use the browser to render my xml file.
It is generated on the server.
I would appreciate any kind of help.
Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209

The commented part of the code is'nt working as expected.
I mean using getResourceAsStream() method was'nt reflecting the changes to the file it was reading.
It was repeatedly getting me the eariler version of the file (when the tomcat engine starts)
But then i used getResource() which returns a URL and then openStream() returns an Inputstream and that seemed to work just fine.(it was picking up the changes)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ClassLoader's getResourceAsStream is caching the InputStream object
 
Similar Threads
XSL Include validation in Rational Application Developer 6.0
Reply to Govind K: XML
Issues with Jar Files and loading images
File not found inside .ear
Read data to the xml file from the database?