Request dispatcher

When a request is received by a servlet, it may choose to either generate the response itself, relinquish processing to another servlet (known as forwarding), or request one or more other servlets to generate portions of the complete response (known as including).

The servlet container provides the request dispatcher mechanism in order to allow a servlet to engage other servlets in generating a response.

A few important rules apply to the process of dispatching a request:

  1. A servlet forwards a request when it is either not interested or not able to generate the response. In this case, it wholly delegates request processing to the forwarded servlet. Any output written by the original servlet is flushed.
  2. Attributes added to a request ...

Get Tomcat 6 Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.