tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vernon Wu <vern...@gatewaytech.com>
Subject Re: Location of application-specific properties files
Date Sun, 04 Aug 2002 16:36:41 GMT

My impression is a set of property files shall be placed somewhere in the path of WEB-INF/classes.


8/4/2002 12:05:29 PM, "Robert Baker" <robertbaker@charter.net> wrote:

>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:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message