tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dave Naden" <>
Subject RE: global parameters--which way
Date Fri, 20 Jun 2003 01:46:56 GMT
Thank  you--very helpful!  

-----Original Message-----
From: Shapira, Yoav [] 
Sent: Wednesday, June 18, 2003 9:06 AM
To: Tomcat Users List
Subject: RE: global parameters--which way


>It seems as though there are (at least) 2 ways to set up global
>parameters at deployment time: 1) put them in a <context-param> tag in
>deployment descriptor, or 2) use a properties file or resource bundle
>read them in.  Is there a preferred or standard way, or does it even 

You were right to state there are at least 2.  Other ways include JNDI (<Resource> tags
in server.xml for tomcat), reading from a service, etc. etc.

Between the above two approaches, ask yourself:
- Who reads these parameters?  Are they servlets/listeners/filters only, POJOs only, or a
mix?  If it's servlets/listeners/filters only, a <context-param> is likely a good choice.
 If it's POJOs only, a .properties file on the classpath is a good choice.  If it's a mix,
either one is a good choice.

The advantage of putting .properties file on the classpath is that you can access them in
your app even if you're not running within a servlet container.  The disadvantage is that
it's more difficult to modify, it's an uglier source organization, it mixes code and configuration.

I usually like properties file placed under WEB-INF, accessed via
ServletContext#getResource() or ServletContext#getResourceAsStream().
This is standard, portable, clean, safe, protects the properties files from the browser.

Yoav Shapira

This e-mail, including any attachments, is a confidential business communication, and may
contain information that is confidential, proprietary and/or privileged.  This e-mail is intended
only for the individual(s) to whom it is addressed, and may not be saved, copied, printed,
disclosed or used by anyone else.  If you are not the(an) intended recipient, please immediately
delete this e-mail from your computer system and notify the sender.  Thank you.

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message