I know it it is easy to read the context-param values from web.xml with a Servlet.
But is it possible to read the value with a normal java class?
I know it it is easy to read the context-param values from web.xml with a Servlet.
But is it possible to read the value with a normal java class?
You can perse web.xml (with something like dom4j), but I guess that's not your point - a context-param
does not make any sense in a non-servlet environment.
I assume you want to obtain the value of an init parameter in a class in your web application that is not a servlet, but is, say, a helper class.
You can - your entry point is always a servlet, so get the context-param
value there and pass it as a method argument to the method you need.
In case this is configuration that you can afford to make static
- load it only once, on init()
of a servlet.