You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Vernon Wu <ve...@gatewaytech.com> on 2002/08/04 18:36:41 UTC

Re: Location of application-specific properties files

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" <ro...@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:   <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>


Re: RE: Location of application-specific properties files

Posted by Vernon Wu <ve...@gatewaytech.com>.
Robert,

I only use property files for the presentation layer. And I place all those files under WEB-INF/classes. It is working on 
TC4.0.4, but not on the 4.1.7b from my test yesterday. Since the way you access the files is different from mine, I can't 
say much about it. What you miss, I guess you, is a small detail. I don't know whether it will help if you read the i18n 
section of the online tutorial again. 

 
8/4/2002 2:24:52 PM, "Robert Baker" <ro...@charter.net> wrote:

>I had thought so as well, but it doesn't work anywhere under
>WEB-INF/classes.
>
>-----Original Message-----
>From: Vernon Wu [mailto:vernonw@gatewaytech.com]
>Sent: Sunday, August 04, 2002 12:37 PM
>To: Tomcat Users List
>Subject: Re: Location of application-specific properties files
>
>My impression is a set of property files shall be placed somewhere in the
>path of WEB-INF/classes.
>
>
>
>--
>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>


RE: Location of application-specific properties files

Posted by Robert Baker <ro...@charter.net>.
I had thought so as well, but it doesn't work anywhere under
WEB-INF/classes.

-----Original Message-----
From: Vernon Wu [mailto:vernonw@gatewaytech.com]
Sent: Sunday, August 04, 2002 12:37 PM
To: Tomcat Users List
Subject: Re: Location of application-specific properties files

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



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>