You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by David Cao <Da...@criticalthinking.com> on 2002/11/19 02:37:15 UTC
update text file under WEB-INF
Help!
I need configure my log4j to put log file under WEB-INF\logs(or maybe
docroot\logs; and I want put my editable config properties into
WEB-INF\conf. I know how to load a property file under WEB-INF. But I
need update that file in program as well.
So how can I:
1 Config log4j?
2 How do load and write the property file under WEB-INF?
Thanks
David Cao
-- Innovation by Critical Thinking
-----Original Message-----
From: JensStutte@quidinfo.it [mailto:JensStutte@quidinfo.it]
Sent: Tuesday, August 06, 2002 6:56 AM
To: Tomcat Users List
Subject: Re: Location of application-specific properties files
You must load your properties through some Classloader that is able to
locate your properties file. For example you can use the class
PropertyResourceBundle for a real properties file or if you want to
access
some own file format, just call the Thread.getCurrentThread
().getContextClassLoader().getResourceAsStream(...) function. Then the
WEB-INF/classes folder or some of your application specific .jar files
in
WEB-INF/lib (if any) is the right place for it (and as far as i know, it
is
the only standard way, which assures you to find a specific file on
every
standard J2EE server).
Hope that helps,
Jens Stutte
"Robert Baker"
<robertbaker@ch To: "Tomcat Users List"
arter.net>
<to...@jakarta.apache.org>
cc:
04/08/2002 Subject: Location of
application-specific properties
21.05 files
Please respond
to "Tomcat
Users List"
I am using Tomcat 4.0.3 under WinXP Pro, and I am trying to get my
application to "find" an application-specific properties file. I am
having
problems trying to determine which directory to put this file in.
Here is the Java code I am using for this class:
//-----------
import java.util.Properties;
import java.io.FileInputStream;
public class ForumProperties extends Properties {
private static final String separator =
System.getProperty("file.separator", ".");
private static final String homeDirectory =
System.getProperty("user.home",".");
private static final String DEFAULT_FILENAME = "forum.properties";
private static ForumProperties globalProps;
private ForumProperties() {
}
private ForumProperties(String fileName) throws Exception {
this();
load(new FileInputStream(fileName));
}
public static ForumProperties getInstance() throws Exception {
try {
if (globalProps == null)
globalProps = new ForumProperties(DEFAULT_FILENAME);
} catch (Exception ex) {
ex.printStackTrace(System.out);
throw new Exception("Error loading properties file");
}
return globalProps;
}
}
//-----------
I have put the properties file in just about every directory I can think
of
to try and find out where it's supposed to be, but I can't get it to
work.
I can put the file into the "user.home" System property (which turns out
to
be C:\Documents and Settings\Administrator) and have it pick it up, but
I
would prefer to put the file into the directory tree of the application.
Is there an attribute or something in the server.xml or web.xml file I
am
forgetting to set?
Can anyone help?
Thanks,
Bob
--
To unsubscribe, e-mail: <
mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <
mailto:tomcat-user-help@jakarta.apache.org>
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>