tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject Re: Where to put .properties so web app finds it
Date Tue, 13 Nov 2001 23:01:55 GMT
On Tue, 13 Nov 2001, MacDonald, Todd wrote:

> Date: Tue, 13 Nov 2001 17:59:42 -0500
> From: "MacDonald, Todd" <Todd_MacDonald@tvratings.com>
> Reply-To: Tomcat Users List <tomcat-user@jakarta.apache.org>
> To: "Tomcat-User (E-mail)" <tomcat-user@jakarta.apache.org>
> Subject: Where to put .properties so web app finds it
>
> I've got a .properties file for settings in the web app that might be
> configured differently depending on which server the .war might be dropped.
>
> It obviously doesn't belong in the .war itself.  Where is the recommended
> place to put such configuration files in Tomcat 4 so that the app will find
> it?
>
> I'm trying hard not to modify the default configuration of T4 much until I
> know more about it.
>

For configuration information that is external to the application, I would
use <Environment> elements to define them in server.xml.  For
configuration information, see:

  http://jakarta.apache.org/tomcat/tomcat-4.0-doc/config/context.html

and scroll down to "Environment Entries".

If you've defined an environment entry named "maxExemptions" that is an
Integer (as in the example in the docs), you can access it from your
program by code like this:

  InitialContext initCtx = new InitialContext();
  Context envCtx = (Context) initCtx.lookup("java:comp/env");
  Integer maxExemptionsObj = (Integer) envCtx.lookup("maxExemptions");
  int maxExemptions = maxExemptionsObj.intValue();

By the way, this is the design pattern used in J2EE application servers to
access externally configured information.  Another use for this approach
is to use externally configured JDBC connection pools -- see:

  http://jakarta.apache.org/tomcat/tomcat-4.0-doc/jndi-resources-howto.html

> -T

Craig


> --
> To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
> For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
> Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>
>
>


--
To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>


Mime
View raw message