1

Let's say I have servlet based web application which uses web.xml to define context parameters:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" version="3.0"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee  http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

    <context-param>
        <param-name>logging.path</param-name>
        <param-value>target/logs</param-value>
    </context-param>

</web-app>

Is there any alternative how one can define context params?

The reason I am asking is that you have e.g. @WebFilter annotation to replace <filter-mapping>s in web.xml

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Patrik Mihalčin
  • 3,341
  • 7
  • 33
  • 68

1 Answers1

1

You can define context paramaters programmatically by setting setInitParameter.

later, fetch it by getInitParameter

Rohit Gaikwad
  • 3,677
  • 3
  • 17
  • 40