3

I have a web application which I wish to configure via settings in an external folder (external to the container and to the .war file). Therefore I want to inject just a single setting into my webapp which is the root folder of my configurations. The reasons for doing this are so that the maintenance team can update configuration settings in nice plain text files without having to re-deploy the war file.

My question is, what is the best way to parametrize a web application in the case of just a single configuration setting. I know I can use a JVM arg and then detect it from my initialization servlet. Ideally, I'd like something that I can put in the server.xml (not the web.xml file) that can be programmatically acquired from my ServletContextListener.contextInitialized(ServletContextEvent paramServletContextEvent) method.

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

1 Answer 1

3

We are using -Dconfig.location=/foo/bar/config.properties and it works fine. It's a JVM arg, so it goes to the startup script.

You can register properties via JNDI in server.xml, but I'm not convinced this is a better option. server.xml or catalina.sh - both are container-level

Sign up to request clarification or add additional context in comments.

2 Comments

And to retrieve it, use System#getProperty("config.location").
Hi, I was trying to avoid the use of a JVM arg (as stated in the question). Is there a way of passing a parameter on a per war basis (via the server.xml file)?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.