On Wed, 20 Feb 2002, GuruPrasad wrote:

> Date: Wed, 20 Feb 2002 10:59:55 -0800 (PST)
> From: GuruPrasad <[EMAIL PROTECTED]>
> Reply-To: Tomcat Developers List <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: Difference between Valve and javax.servlet.Filter?
>
> What are the difference between Valve and Filter?
>

Valves and Filters implement the same design pattern ("Chain of
Responsibility" from the GoF book), so they can be used for similar sorts
of things.  However, there are a couple of key differences:

* Filters are part of the servlet spec, and therefore portable
  to any Servlet 2.3 environment, while Valves are specific
  to Tomcat 4.x.

* Filters have access to ServletRequest and ServletResponse objects,
  and can optionally wrap them to provide modified functionality.
  Valves have access to the internal Request and Response implementation
  objects, which have a lot more functionality -- you can often
  implement things by calling a property setter on the object directly
  instead of by wrapping it.

The rule of thumb to use:  if you can implement your required
functionality as a Filter or as a Valve, use a Filter to protect the
portability of your application.

> -
> Thanks,
> prasad
>

Craig


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

Reply via email to