RequestDispatcher in Servlet with Example

By | August 16, 2011
RequestDispatcher in Servlet with Example. You can find RequestDispatcher Concept and example Program in this page.

The RequestDispatcher object is used to send a client request to any resource  on the server Such a resource may be dynamic (e.g. a Servlet or a JSP file) or static (e.g. a HTML document)

To send a request from resource x  to resource y,  we need to create RequestDispatcher object. This has been done in 3 ways:
  • HttpServletRequest.getRequestDispatcher(“url”);
  • Servlet.getServletContext().getRequestDispatcher(“url”);
  • Servlet.getServletConfig().getServletContext().getRequestDispatcher (“url”);
RequestDispatcher object  is used to
  • forward the request from one resource to another in Server
  • include the response of one resource into another
Forwarding or including will be done  at server side so client  don’t have
any information.

No related content found.

Leave a Reply

Your email address will not be published. Required fields are marked *