tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject Re: context-param
Date Sun, 02 Sep 2001 05:05:22 GMT

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

> Date: Tue, 28 Aug 2001 13:41:07 -0500
> From: "Mills, Theo" <theo.mills@twc.state.tx.us>
> Reply-To: tomcat-user@jakarta.apache.org
> To: "'tomcat-user@jakarta.apache.org'" <tomcat-user@jakarta.apache.org>
> 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



Mime
View raw message