Metawerx Java Hosting Small Logo

<context-param>

This tag provides parameters to the entire context / web application.

Uses include things like defining an administrator email address to send errors from your application, or other settings that are relevant to your application as a whole.

See advantages of specifying parameter values in web.xml for reasons you would want to use this method.

To access the values from your Java/JSP code, use the following syntax:

String value = getServletContext().getInitParameter("parameterName");

A single <context-param> tag is used for each parameter.

The actual parameter name and value are set using <param-name> and <param-value>.

Example usage in web.xml:

<context-param> 
    <description>The email address of the administrator, used to send error reports.</description> 
    <param-name>webmaster</param-name> 
    <param-value>address@somedomain.com</param-value> 
</context-param> 

With the above example, you can extract the value of the webmaster parameter with:

String value = getServletContext().getInitParameter("webmaster");

See Also

navigation
metawerx specific
search
Share
tools
help

referring pages

Share