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.


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