tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject Re: need request lifecycle diagram
Date Mon, 02 Dec 2002 02:53:06 GMT

On Sat, 30 Nov 2002, AAron nAAs wrote:

> Date: Sat, 30 Nov 2002 11:14:22 -0500
> From: AAron nAAs <>
> Reply-To: Tomcat Users List <>
> To:
> Subject: need request lifecycle diagram
> Does anyone know of a good request lifecycle diagram showing all the steps
> in satisfying a Java Server request?
> I'd like to see the exact ordering of all the components that a request goes
> through such as Authentication, Filters, Listeners, Valves, etc... Either a
> vendor specific or a generic Java Server diagram would suffice.

Here's a brief list for Tomcat 4 standalone (if you're behind a web server
there are some additional stages before and after) here's a brief summary
of the lifecycle's stages:

* Connector -- receives HTTP connection from client browser,
  dispatches request to the associated Engine.

* Engine -- runs all Valves nested in the Engine, including
  one that dispatches the request to the appropriate Host
  based on the requested host name.

* Host -- runs all Valves nested in the Host, including
  one that dispatches the request to the appropriate Context,
  based on the requested context path

* Context -- runs all Valves nested in the Context, including
  one that dispatches the request to the appropriate servlet
  Wrapper, based on the servlet mapping that matches.

* Wrapper -- loads the servlet (and calls init() if needed).
  Runs all the filters mapped to this request URI, followed
  by a call to the service() method of the servlet itself.

A couple of notes on interesting subtleties:

* Listeners aren't directly invoked as part of the request
  processing lifecycle for Tomcat 4 (although you can declare
  a ServletRequestListener in Tomcat 5 that will be invoked
  before the filters).

* A lot of Tomcat's standard processing features are implemented
  as Valves that are explicitly added (like the access log valve
  in the default configuration) or dynamically configured if
  necessary.  Authentication is an example of the latter -- at
  webapp startup time, Tomcat looks at your web.xml file and (if
  you've specified a login method) adds an appropriate Authenticator
  valve to the list of valves run at the Context level.

* If your app uses a request dispatcher, you'll find that filters
  and authentication are *not* applied to the dispatched request.
  They are only applied on the original request from the client.

> Everything I've found so far talks about one of these at a time, so the big
> picture is never revealed. I want to know, for instance, if filters are
> applied before or after authentication.

Based on the above information, we can see that filters are applied
*after* authentication, not before.

> Thanks,
> -AAron


> _________________________________________________________________
> Add photos to your e-mail with MSN 8. Get 2 months FREE*.
> --
> To unsubscribe, e-mail:   <>
> For additional commands, e-mail: <>

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message