tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject Re: Setting context parameters with XML files?
Date Tue, 05 Sep 2000 16:58:49 GMT wrote:

> Is it possible to set context parameters using one of the .xml files?  If
> so, how is it done?
> Right now I'm using a servlet that loads on tomcat start-up and calls
> getServletContext().setAttribute(name, value);.
> This works, but seems kind of clumsy.

It is possible to set context *initialization parameters*, but not
attributes, in the web.xml file:

        <param-value>My parameter value</param-value>

which you can read with:


To initialize servlet context attributes, the most common technique is to
create a special initialization servlet and configure it to load on startup.
Then, set up the attributes you need in the init() method.

In the servlet 2.3 spec (public draft currently available at, an additional technique called
application events is being added.  You will be able to register a class that
should receive notification when the web application is started up or shut
down, and you can configure your servlet context attributes there.

> Thanks in advance,
> Brian King

Craig McClanahan

See you at ApacheCon Europe <>!
Session VS01 (23-Oct 13h00-17h00):  Sun Technical Briefing
Session T06  (24-Oct 14h00-15h00):  Migrating Apache JServ
                                    Applications to Tomcat

View raw message