tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Miklancic, Daniel J" <>
Subject RE: Default file locations for .properties file
Date Wed, 21 Nov 2001 15:12:53 GMT

Calling PropertyLoader.load("/"); returns the property
file which is stored in WEB-INF/classes.  This would  meet your objective of
having each context have its properties file stored separate from the others
-- the name is relative to the context.  

The class I commonly use to read properties files follows:  

public class PropertyLoader

	private PropertyLoader() { } // Prevent public construction

   * Loads the property file specified.
   * @param propertyFilename the name of a property file.
   * @returns a Properties objects with the contents of the specified
   * file, or null if the file does not exists or cannot be located.
   * @throws IOException if an error occurs in locating or reading the
   * file.
  public static Properties load(String propertyFilename)
    Properties props = null;
    try {
	InputStream is =
	if (is != null)
	  props = new Properties();
	  props.load( is );
    catch (IOException ioe) { }
    return props;

-----Original Message-----
From: Roger Varley []
Sent: Wednesday, November 21, 2001 9:53 AM
Subject: Default file locations for .properties file


I have a servlet running under Tomcat 3.2 that reads and writes to a
properties file created by the Properties class. If I only provide the
unqualified name of the properties file in my servlet, Tomcat reads and
writes the file to the %TOMCAT_HOME% directory. This is consistant with the
documentation in the server.xml file. The comments go onto say that I can
specify a "home" parameter that will be used to represent the base directory
for all relative paths, but these comments appear in a section of server.xml
that appears to be concerned with global configuration. So I'm concerned
that because the "all" is unqualified that by setting this "home" parameter
I will disrupt the "webapps/<contextname>/web-inf behaviour and that all my
properties files will appear in the same directory

I am running a number of different contexts and I would like each properties
file to appear somewhere within the directory structure for each context
without having to specify the absolute path in each servlet.

I hope that this makes sense.

"You can lead a horse to water but you can't make him drink,
and shooting the rider because his horse allowed itself to
get dehydrated is not the proper response," Lane Thomas

Do You Yahoo!?
Get your free address at

To unsubscribe:   <>
For additional commands: <>
Troubles with the list: <>

To unsubscribe:   <>
For additional commands: <>
Troubles with the list: <>

View raw message