Request Dispatcher
The RequestDispatcher interface provides the facility of dispatching the request to another resource it may be html, servlet or jsp.
public void forward(ServletRequest request,ServletResponse response)throws ServletException,java.io.IOException{
//Forwards request
}
public void include(ServletRequest request,ServletResponse response)throws ServletException,java.io.IOException{
//include Resource
}
How to create Request dispatcher and use it
RequestDispatcher rd=request.getRequestDispatcher(myServlet);
rd.forward(request,responce);
A simple example of it could be on Place order button servlet validate request if its valid then send to order placed page else will send to error page or info missing page.
The RequestDispatcher interface provides the facility of dispatching the request to another resource it may be html, servlet or jsp.
public void forward(ServletRequest request,ServletResponse response)throws ServletException,java.io.IOException{
//Forwards request
}
public void include(ServletRequest request,ServletResponse response)throws ServletException,java.io.IOException{
//include Resource
}
How to create Request dispatcher and use it
RequestDispatcher rd=request.getRequestDispatcher(myServlet);
rd.forward(request,responce);
A simple example of it could be on Place order button servlet validate request if its valid then send to order placed page else will send to error page or info missing page.
Comments
Post a Comment