RequestDispatcher is the interface which dispatches the request from one resource to another resource. It may be Html, Servlet or jsp.
This interface can also be used to include the content of another resource also.
There are two methods in this interface:
1.public void forward(ServletRequest request,ServletResponse response)throws ServletException,java.io.IOException
Forwards a request from a servlet to another resource (Servlet, Jsp or Html).
Example:
RequestDispatcher rd=request.getRequestDispatcher("servlet2");
rd.forward(request, response);
2.public void include(ServletRequest request,ServletResponse response)throws ServletException,java.io.IOException
Includes the content of a resource (Servlet, Jsp or Html ).
Example:
RequestDispatcher rd=request.getRequestDispatcher("/index.html");
rd.include(request, response);