-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Eric,

On 6/28/2010 11:37 PM, Eric P wrote:
> I've been loading up my web.xml with context and init params for my
> first app, but I'm thinking at some point it'd be nice to tweak these
> values on the fly while the app is running.
> 
> What are some good practices to accomplish this?
> 
> I'm leaning towards storing all application variables in a database
> table w/one record, and loading these values into the application scope
> w/a servlet on app startup.  Then if I need to tweak any values I could
> update the db record and hit this servlet to reload all the application
> scope vars.

I think this seems like a reasonable idea. I would use a
ServletContextListener to trigger the initial load from the db or other
data source (properties file, etc.).

You could even use variables from web.xml in <init-param>s if you want.
The only caveat to this option is that you can't very well change
web.xml during runtime and re-load the vars. Instead, you'd have to have
a mechanism to change those variables either manually and individually
(like an admin "system settings" page), or load from another data
source, at which point you may as well forget <init-param>s in the first
place.

You'll want to use a servlet, of course, for re-loading your settings
from file/db/etc. I would recommend making the aforementioned
ServletContextListener and this servlet share a helper class that loads
and settings and puts them into the application scope. Heck, you can
even use a single class that is a servlet but also implements
ServletContextListener, and have everything in one class.

Hope that helps,
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkwv7SUACgkQ9CaO5/Lv0PAyBQCggcLWFKXPqTSksO5dUVORJ8ih
LtQAoK6wZbIArJSQe1pZ9fqeGWtn/PvV
=Vdua
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to