tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pedro Salazar <>
Subject open xml/xsl files inside classpath
Date Tue, 26 Jun 2001 13:23:44 GMT

I have a servlet which read some properties (using the ResourceBundle) 
from a properties file in a package PT.teste.props where exists a 
relation like this:

fileA.xml = file1.xsl
fileB.xml = file2.xsl

Of course getting the properties file is simple task because I just use 
the location in classpath, ex:


But, now I would like to open both files, the xml and the xsl file, 
which are in a package PT.teste.xml. I tested using the absolute path to 
them, but is not very recommendable because tomorrow I probably will put 
it in another location or in another machine...

Source xmlSource = new (new"file:///opt/jakarta-tomcat-3.2.1/webapps/servlet_teste/WEB-INF/classes/PT/teste/xml/fileA.xml").openStream());
Source xslSource = new (new"file:///opt/jakarta-tomcat-3.2.1/webapps/servlet_teste/WEB-INF/classes/PT/teste/xml/file1.xsl").openStream());

Is there a easy way to open a file in a classpath directly? Or at least 
a way where the path is relative to the web application? A not very 
recommendable way just to solve my problem is use a path in a properties 
file which I would read in the init() of servlet... but, I wouldn't like 
to do it!

Pedro Salazar.

View raw message