How to get context-param value in web.xml
<context-param>
is the static parameter and defined in web.xml
file. We often use it to store some data, that does not change frequently. For example, we store the path of the configuration file, store email addresses, and so on.
web.xml
<context-param>
<param-name>configFilePath</param-name>
<param-value>/app/config.xml</param-value>
</context-param>
Using the following code in either a JSP or Servlet to get the above configFilePath
context param value:
String value = getServletContext().getInitParameter("configFilePath");
System.out.print(value); // /app/config.xml