Re: Servlet reading config file from ?? path

From: Magnus Anvin (mav_at_oss.teleca.se)
Date: 02/18/04


Date: 18 Feb 2004 02:11:38 -0800


"Moth" <not@this.address> wrote in message news:<geGXb.56668$Wa.54293@news-server.bigpond.net.au>...
> I have a web application that needs to read an xml configuration file. How
> can I specify this without knowing the path of the web application?
>
> I've tried using ClassLoader.getSystemResourceAsStream(filename) but this
> doesn't seem to work for my servlet even with the config file in the lib
> folder of the web app.
>
> Can anyone give me any pointers?

I do not know if you are using Tomcat, but if you are I think you
should try to put the file in the /WEB-INF/classes directory of your
application. In this directory you should put classes and resources
that are unpacked. Classes and resources in jar-files should be put in
the /WEB-INF/lib. Classes and resources that are put in these
directories are visible only to the containing web application, but to
no others.



Relevant Pages

  • Re: Where should I put my configuration file?
    ... the configuration file cannot be found. ... How about image files which I place under a folder called "images"? ... Should I simply put the folder under the application root, ... try using them as external resources. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Adding Configuration Files to resources
    ... resources in VB6? ... What sort of configuration file? ... In the Microsoft 'certified for vista test cases' there is a test (#1 ...
    (microsoft.public.vb.general.discussion)
  • Servlet reading config file from ?? path
    ... I have a web application that needs to read an xml configuration file. ... can I specify this without knowing the path of the web application? ...
    (comp.lang.java)
  • Re: Servlet reading config file from ?? path
    ... > I have a web application that needs to read an xml configuration file. ... > can I specify this without knowing the path of the web application? ... and can be read via standard Servlet API methods. ...
    (comp.lang.java)
  • Re: Adding Configuration Files to resources
    ... resources in VB6? ... What sort of configuration file? ... Sorry, but "didn't work" should be words no programmer ever utters to another, ...
    (microsoft.public.vb.general.discussion)