tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
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" <>
> Reply-To: Tomcat Users List <>
> To: "Tomcat-User (E-mail)" <>
> 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:

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:

> -T


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

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

View raw message