How to parameterize initialization of a web application (rather than a servlet)

I have a web application that I want to configure using the settings in an external folder (external for the container and in the .war file). Therefore, I want to insert only one parameter in my webapp, which is the root folder of my configurations. The reason for this is that the maintenance team can update the configuration settings in good text files without the need to redeploy the war file.

My question is what is the best way to parameterize a web application in case of only one configuration parameter. I know that I can use the JVM arg and then discover it from my initialization servlet. Ideally, I would like something that I can add to the server.xml file (and not the web.xml file), which can be programmatically retrieved from my ServletContextListener.contextInitialized (ServletContextEvent paramServletContextEvent) method.

Is there a way to do this using the ServletContextListener approach or is this another way?

+3
source share
1 answer

We use -Dconfig.location=/foo/bar/config.propertiesand it works great. This is a JVM arg, so it proceeds to run the script.

JNDI server.xml, , . server.xml catalina.sh -

+3

All Articles