using
the ServletContext object like
context.getRealPath("/");
this will give you
c:\....\....\webapps\myapp\ ( the start directory of your
context )
then get the file seperator
( using system.getProperty(file.seperator) ) then add it
to the string
OK I will right the
code.
String file = new
String("file_name");
Sring path = new
String("");
path =
context.getRealPath("/");
String fs =
System.getProperty( file.seperator );
path = new String (
path + fs + "WEB-INF" + fs + "classes" + fs + file_name ) ;
Now path will have the file
name .....
-----Original Message-----hello,
From: randie ursal [mailto:[EMAIL PROTECTED]]
Sent: 28 August 2002 02:30
To: [EMAIL PROTECTED]
Subject: reading a property file
i have a situation here:
i want that i can change my property file dynamically without
restarting Tomcat.
i tried implementing it using the suggestion that was given to me by
some of the people here which is to place the property file on the
WEB-INF/classes directory and read it using this statement:
Properties oProp = new Properties();
oProp.load(this.getClass().getResourceAsStream
("/CommandServer.properties")';this works fine. but the problem is when i change the property file dynamically while tomcat is running my changes doesn't take effect. the same default value was read. so, what i did was i make use of the File class to read the property file and implement it like this: File ofile = File ("..\\webapps\\myapp\\WEB-INF\\classes\\ com\\test\\MyProperty.properties"); FileInputStream oIn = new FileInputStream(oFile); Properties oProp = new Properties(); oProp.load(oIn); this also works, and i am able to change my property file dynamically. my question is, how do i place my property file so that when i read it using File class i don't have to include the "..\\webapps\\myapp\\WEB-INF\\classes" extra path...instead just read it directory from my package directory structure. is there a way Tomcat can read my property file that way? thanks in advance randie
