I have a web app in Java, which uses some external program (invokes a command line tool).
I want to make the path of the command line program configurable, so that I can change it without re-building my application.
Questions:
1) Which exactly parameter should I use (out of those available in web.xml), if it is set only once (at deployment) and thereafter never changes?
2) How can I access this parameter inside my Java code?
Thanks in advance
Dmitri
web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app>
<context-param>
<param-name>command</param-name>
<param-value>SOME_COMMAND</param-value>
</context-param>
.
.
.
.
</web-app>
Java code
String commandToExecute = getServletContext().getInitParameter("command");
Alternatively
You can also put this thing in property/xml file in the classpath read it and put it to servlet context when context initializes.
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