On Tue, 13 Nov 2001, MacDonald, Todd wrote:

> Date: Tue, 13 Nov 2001 17:59:42 -0500
> From: "MacDonald, Todd" <[EMAIL PROTECTED]>
> Reply-To: Tomcat Users List <[EMAIL PROTECTED]>
> To: "Tomcat-User (E-mail)" <[EMAIL PROTECTED]>
> 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:[EMAIL PROTECTED]>
> For additional commands: <mailto:[EMAIL PROTECTED]>
> Troubles with the list: <mailto:[EMAIL PROTECTED]>
>
>


--
To unsubscribe:   <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>

Reply via email to