On Tue, 28 Aug 2001, Mills, Theo wrote:

> Date: Tue, 28 Aug 2001 13:41:07 -0500
> From: "Mills, Theo" <[EMAIL PROTECTED]>
> Reply-To: [EMAIL PROTECTED]
> To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
> Subject: context-param
>
> Anyone know how to access an application-wide context-param from a servlet?
>

The simplest way is to use a context parameter in your web.xml file:

  <context-param>
    <param-name>global-name</param-name>
    <param-value>This is the parameter value</param-value>
  </context-param>

which you can retrieve from a servlet by calling:

  getServletContext().getInitParameter("global-name");

NOTE:  There are rules you *must* follow about the order of elements in
your web.xml file -- see the Servlet Specification, which you can download
from:

  http://java.sun.com/products/servlet/download.html

Craig McClanahan


Reply via email to