What is a Request Dispatcher?

The request dispatcher provides an interface for routing requests to other resources in the same application, such as Java Server Pages (JSP), images, HTML, or another servlet. It may also be used to combine replies from different servlets so that the client receives the request from both. It can also be used to pass the client’s request on to the next servlet.

In a Requestdispatcher interface, there are two methods defined:

  • void include(): Before delivering the response, it incorporates the content of the resource.
  • void forward(): this function passes the request from one servlet to another on the server, such as a JSP or an image.