I basically need to pass an argument to the WAR file that contains the path to my config.json
.
I want to achieve it in such a way so that once the project has been exported as a WAR file, I should be able to change the argument without opening the WAR file and having to export it again.
I understand I can pass arguments in the web.xml
which can be obtained in the servlet but wouldn't changing the web.xml
require me to open the WAR file?
I am using jetty-runner.jar
to deploy my webapp.
When you run jetty-runner.jar, you may pass a proprty to jvm like this
java -jar jetty-runner.jar my.war -Dproperty.name=value
In your web.xml you may use following syntax
<context-param>
<param-name>property.name</param-name>
<param-value>${property.name}</param-value>
</context-param>
See an example here: http://www.xinotes.net/notes/note/1611/
I can see 2 solution to you problem:
1) You define an environment variable that specifies the path to your config.json on the server that hosts you jetty instance
2) You add to the class path the folder that contains the config.json and access it from your web application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With