Java Reference
In-Depth Information
The
RequestDispatcher
Interface
public interface RequestDispatcher
B
The
RequestDispatcher
interface defines an object that can serve as a wrapper around another
resource on the server. It is most often used to forward requests to other server resources. It
defines two methods.
The
forward()
Method
public void forward(ServletRequest request,
ServletResponse response)
throws ServletException,
java.io.IOException
The
forward()
method is used to forward a request from one servlet to another. It allows the
first servlet to perform some initial tasks on the request before forwarding it to another
resource on the server.
forward()
returns no value.
forward()
has two parameters:
•
ServletRequest
•
ServletResponse
It throws these exceptions:
•
ServletException
•
java.io.IOException
The
include()
Method
public void include(ServletRequest request,
ServletResponse response)
throws ServletException,
java.io.IOException
The
include()
method is used to merge content from another server resource in the response
of the final servlet.
include()
returns no value.
include()
has two parameters:
•
ServletRequest
•
ServletResponse
It throws these exceptions:
•
ServletException
•
java.io.IOException