On Mon, 13 Jan 2003, Filip Hanik wrote:

> Date: Mon, 13 Jan 2003 21:13:16 -0800
> From: Filip Hanik <[EMAIL PROTECTED]>
> Reply-To: Tomcat Developers List <[EMAIL PROTECTED]>
> To: Tomcat Developers List <[EMAIL PROTECTED]>
> Subject: RE: Valve question
>
> what places can I define <valve> in?

You mean in server.xml?  It can go inside an <Engine>, a <Host>, or a
<Context>.

Where you define it determines which subset of requests that the Valve
implementation actually sees:

* Nested in <Engine> -- sees all requests for all virtual hosts and
  webapps.

* Nested in <Host> -- sees all requests for this virtual host.

* Nested in <Context> -- sees all requests for this webapp.

> actually casting request as HttpRequest seems to work fine,
> ((HttpRequest)request).getContext().getManager() seems to be just dandy :)

As long as your Valve is nested inside a <Context> (which makes sense for
something related to clustering a particular webapp) this will work.  If
the valve was nested in an engine or a host, the getContext() method would
return null and this would still cause an NPE.

> but I would still like where I can define valve, you are saying I can define
> it under a specific context and under the entire engine for all requests?
>

Yes ... but a Valve nested in an engine or a host doesn't know what webapp
will be processing this request, because that's not actually decided until
StandardHostValve (the last Valve in the chain for a particular <Host>) is
executed.

> Filip

Craig


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

Reply via email to