tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject Re: T4 architecture question: Valves vs. Servlet Filters
Date Tue, 28 Nov 2000 20:33:11 GMT
Christian Mallwitz wrote:

> Hi,
> I had a look at the Tomcat 4.0 document "Comparing RequestInterceptor and
> Valve Technology". From what I understand Valves are an improvement.
> But: How do Valves compare to ServletFilter?

The similarities are not accidental :-).  In other words, I was on the servlet
expert group for JSR-053 that ended up with the filters API, and was able to
track things from both points of view.

Basically, Valves and Filters are useful for the same types of needs.  The key

* Valves are inside the "container", and are therefore
  specific to Tomcat 4.0.  Filters are inside the "application"
  and are therefore portable to any 2.3 servlet container.

* Valves have direct access to the container's internal
  representation of requests and responses, so they can
  modify these objects without having to wrap them.  In
  filters, you have to use request and response wrappers
  to indirectly modify their behavior.

* Valves have direct access to the other internal components
  of Tomcat, so they can theoretically do anything (pretty much
  the same principle as what a device driver can do when you
  add it to an operating system).  Filters have access to the
  servlet context in which they are running.

> Thanks
> Christian
> --
> Christian Mallwitz INTERSHOP Communications Germany
> Senior Software Engineer    phone: +49 3641 894 334

Craig McClanahan

View raw message