Java Servlet Programing Laungage

Java Servlet Projects

Servlet Project 3

adplus-dvertising
Java Servlet :RequestDispatcher in Servlet and some methods of RequestDispatcher interface
Previous Home Next

javax.servlet.RequestDispatcher is an interface of servlet API ,implemantation of which is provided by the vendor. RequestDispatcher object is used by the servlet to forward the request to another web resource to include the contents of another web resource.

Commonly used methods of RequestDispatcher interface:

include():
Syntax:
public void include (ServletRequest request,ServletResponse response)
						throws ServletException,IOException ;
forward():
Syntax:
public void forward(ServletRequest request,ServletResponse response) 
throws ServletException,IOException ;

Note:- In case of forward, contents are generated only by the forwarded resource that is forwarding servlet doesn't generate response.

getRequestDispatcher():

Method of ServletRequest interface is used to obtain a request dispatcher object for a resource.

Syntax:
public RequestDispatcher getRequestDispatcher(String URL of resource);
Previous Home Next