Thank  you--very helpful!  

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



Howdy,

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

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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to