Use the Environment Entries section to add, remove, and view the web application's environment variables. Application environment entries are initialization variables that are available throughout a web application. You can use them, for example, to validate the object's type.
You access application environment variables in the java:comp/env context through a JNDI lookup, unlike context parameters, which you access via a ServletContext object. So, you would extract the value of an application environment variable as follows:
InitialContext context = new InitialContext(); String header = (String) context.lookup("java:comp/env/headerPage");
The JNDI lookup method expects the type specified by the env-entry-type element and throws an exception if the returned value is not of that type.
To declare an application environment variable, you must register it in the web.xml file. When you do this, you provide information needed by the server to use the parameter. You tell the server which value should be returned when an environment entry is referred to in the web application.
You open the web.xml Visual Editor from the Projects window by expanding the Web Pages node, then the WEB-INF node, and then double-clicking the web.xml file. Click References at the top of the editor to open the References section, then click the Environment Entries header to open the Environment Entries section.
Click Add to define an environment entry element with the following properties: