Stick the resource in along with the JAR. Then they will be loaded together and a 
simple call to the file without
a path should discover it



-----Original Message-----
From: Stephan Wiesner [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, December 19, 2001 9:36 AM
To: Tomcat Users List
Subject: How to find a file from a class with Tomcat


I have a Servlet S.java which uses a class C.java (not a servlet itself,
could make it one if I had too).
C.java needs to read a config file. The problem is that this class thinks it
is in c:/ or wherever I started the tomcat server from. I can use
this.getClass().getResource(fileName); but that only works with
Properties.load(), not with a FileInputStream.
So at the moment I have all my paths hardcoded into the classes and of
course I don't want that.

My server.xml contains:
        <Context path="/examples"
                 docBase="d:/jdk1.3/jakarta-tomcat-3.2.3/webapps/examples"
                 crossContext="false"
                 debug="9"
                 reloadable="true" >
        </Context>

And the local web.xml:
   <servlet>
      <servlet-name>hi</servlet-name>
      <servlet-class>HelloWorldExample</servlet-class>
   </servlet>
<servlet-mapping>
      <servlet-name>hi</servlet-name>
      <url-pattern>/hi/*</url-pattern>
   </servlet-mapping>


Any tipp would be appreciated.

Stephan Wiesner


--
To unsubscribe:   <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>


--
To unsubscribe:   <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>

Reply via email to