tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
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 <drevil@sidereal.kz>
> Reply-To: Tomcat Users List <tomcat-user@jakarta.apache.org>
> To: tomcat-user@jakarta.apache.org
> 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
  servlets.)

Craig



--
To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>


Mime
View raw message