0% found this document useful (0 votes)
3 views

context initialization Parameter

The <context-param> tag is used to define parameters for a web application, such as an administrator's email for error reporting. Each parameter is specified with <param-name> and <param-value> within the tag. Accessing these parameters in Java/JSP code can be done using the getServletContext().getInitParameter() method.

Uploaded by

swoobhai
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

context initialization Parameter

The <context-param> tag is used to define parameters for a web application, such as an administrator's email for error reporting. Each parameter is specified with <param-name> and <param-value> within the tag. Accessing these parameters in Java/JSP code can be done using the getServletContext().getInitParameter() method.

Uploaded by

swoobhai
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

<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>[email protected]</param-value>
</context-param>

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

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

You might also like