* Craig R. McClanahan <[EMAIL PROTECTED]> [1153 17:53]:
> 
> On Wed, 27 Nov 2002, Rasputin wrote:
> 
> > * Andy Eastham <[EMAIL PROTECTED]> [1140 16:40]:

> > > Rasputin,
> > > It's in web.xml

> > Sorry, I can't see it.
> >
> > There's a
> >
> > <context-param>
> >
> > element, but I need a context *attribute*, and I don't think they
> > can be set in tomcat.

> The <context-param> element, as you note, sets a context init
> parameter, not a context attribute.  Context
> attributes must be set programatically, not from a web.xml file.

Gotcha - makes sense actually, as getInitParameter returns a String,
whereas getAttribute returns an Object.

> A convenient way to set things up is to create a ServletContextListener
> (assumes you're running Tomcat 4 or later) and configure it in a
> <listener> element in web.xml.  The contextInitialized() method will be
> called when your web application is first started, and that is a perfect
> place to set up whatever context attributes you need.

Lovely, that's the sort of mechanism I was looking for - is it portable
between servlet containers though?
For the record, the load-on-startup hack works pretty well. Cheers.


-- 
Rasputin :: Jack of All Trades - Master of Nuns

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to