You have several Options.
Just one: getResourceAsStream().

I think others will provide other solutions.
which is the best, depends on your needs.

> -----Urspr�ngliche Nachricht-----
> Von: Stephan Wiesner [mailto:[EMAIL PROTECTED]]
> Gesendet: Mittwoch, 19. Dezember 2001 15:36
> An: Tomcat Users List
> Betreff: 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