I found this in the archives (http://marc.theaimsgroup.com ).  You might
search them for more info if this doesn't work.  If you put the file in your
servlet's classpath, this code, which in this case is accessing a properties
file, should allow you to access the file. 

-----------------

InputStream is = this.getClass().getResourceAsStream("myapp.properties"); 
Properties p = new Properties(); 
try 
{ 
   p.load(is); 
} 
catch ( java.io.IOException e ) 
{ 
// Can't load props file 

-----Original Message-----
From: Chris McNeilly [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 29, 2001 11:32 AM
To: [EMAIL PROTECTED]
Subject: Servlets and relative paths


I've got a servlet and am trying to open files.  The problem is that its
defaulting to the tomcat/bin directory whenever I attempt to refer to
them.  How can I change this?  Hardcoding the path isn't such a good
idea as my dev environment is different from production.  These are xml
and xsl files and they are located on the webroot.

Thanks,

Chris

Reply via email to