tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject Re: RequestDispatcher.forward() and filters
Date Sun, 11 Nov 2001 00:18:03 GMT
On 10 Nov 2001, Dr. Evil wrote:

> Date: 10 Nov 2001 22:12:35 -0000
> From: Dr. Evil <>
> Reply-To: Tomcat Users List <>
> To:
> Subject: RequestDispatcher.forward() and filters
> I am trying to figure out what Tomcat does when a filter calls
> RequestDispatcher.forward().
> Obviously, if this happens, the next filter in the chain doesn't get
> called.  The question is, does the forward() method start a new chain
> for this new "request", or does the request just happen without any
> more filters?

There are a couple of questions here that are worth answering
specifically, based on the final version of the 2.3 spec:

* Can a Filter call a RequestDispatcher?  Yes -- for example,
  you could implement an MVC-style controller (similar to the
  Struts ActionServlet) as a Filter that used individual servlets
  as Actions.

* If a Filter calls a RequestDispatcher, does that stop the
  current Filter chain?  Only if you don't call chain.doFilter()
  after the RequestDispatcher.forward() or RequestDispatcher.include()
  call returns.  It's up to you to decide whether to continue the
  chain or not.

* On a RequestDispatcher call, does the newly selected servlet get
  its own filter chain?  No -- filter chains are only constructed based
  on the original request URI.  Servlets that are selected via a
  RequestDispatcher are invoked directly, with no further filters
  involved.  (This is also true for RequestDispatcher calls from


To unsubscribe:   <>
For additional commands: <>
Troubles with the list: <>

View raw message