If you don't want to be tied to the servlet you could use the class loader
by doing something like one of the following:

// Use this if you don't care where the file is located (just doing reads)
this.getClass().getResourceAsStream("xyz.properties")

// Use this if need to know where the file is located (writing back to the file)
URL resUrl = this.getClass().getClassLoader().getResource("xyz.properties");
if (resUrl != null) {
    Properties props = new Properties();
    FileInputStream fs = new FileInputStream(resUrl.getFile());
    props.load(fs);
}





Ludovic Maitre <[EMAIL PROTECTED]>@sophia.inria.fr on
07/27/2001 09:14:35 AM

Please respond to [EMAIL PROTECTED]

Sent by:  [EMAIL PROTECTED]


To:   [EMAIL PROTECTED]
cc:

Subject:  Re: Default folder in Tomcat


hello,

you can obtain the path where your application is located with the
following function :
WEBAPP_ROOT = getServletConfig().getServletContext().getRealPath()
this is obtained from the sample file realpath.jsp, that i sugger you
read.
After obtaining the location of your webapp, simply add WEB-INF + the
name of the property file.

[EMAIL PROTECTED] wrote:
>
> Hello,
>
> I am using Tomcat for the first time, I have a doubt, can someone help
> me with that please.
>
> I am refering to some properties files from my Bean.
> I do not want to hardcode the path in my code.
> Can someone plesae tell me the default folder
> that the server reads from. I tried putting my files
> in my webapps folder , it doesnt seem to work.
>
> Thanks in advance.
> regs
> M

--
 [EMAIL PROTECTED]

 INRIA - 2004 route des lucioles - BP 93    Tel: (33/0) 4 92 38 50 41
 06902   SOPHIA-ANTIPOLIS cedex (France)    Fax: (33/0) 4 92 38 76 02



Reply via email to