Your SlideShare is downloading. ×
  • Like
Servlet chaining
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.


Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply


Published in Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads


Total Views
On SlideShare
From Embeds
Number of Embeds



Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

    No notes for slide


  • 1. Servlet Chaining Team Emertxe
  • 2. Definition Servlet Chaining means the output of one servlet act as a input to another servlet. Transfering the control from one servlet to another servlet.
  • 3. How do we perform servlet chaining? RequestDispatcher • This method is declared in RequestDispatcher Interface. • Signature: forward(ServletRequest request, ServletResponse response)  sendRedirect • This method is declared in HttpServletResponseInterface. • Signature: void sendRedirect(String url)
  • 4. RequestDispatcher The RequestDispacher interface provides the facility of dispatching the request to another resource it may be html, servlet or jsp.This interface can also be used to include the content of antoher resource also. It is one of the way of servlet collaboration. There are two methods defined in the RequestDispatcher interface.
  • 5. Methods of RequestDispatcher interface  The RequestDispatcher interface provides two methods. They are:  public void forward(ServletRequest request,ServletResponse response)throws ServletException, a request from a servlet to another resource (servlet, JSP file, or HTML file) on the server.  public void include(ServletRequest request,ServletResponse response)throws ServletException, the content of a resource (servlet, JSP page, or HTML file) in the response.
  • 6. RequestDispactcher :Example RequestDispatcher rd=null; rd=request.getRequestDispatcher("servlet2" ); //servlet2 is the url //pattern of the second servlet rd.forward(request, response);//method m ay be //include or forward
  • 7. sendRedirect When we want that someone else should handle the response of our servlet, then there we should use sendRedirect() method. This method is in HttpServletResponse interface. It is used to redirect response to another resource, it may be servlet, jsp or html file.
  • 8. sendRedirect  In send Redirect whenever the client makes any request it goes to the container, there the container decides whether the concerned servlet can handle the request or not.  If not then the servlet decides that the request can be handle by other servlet or jsp. Then the servlet calls the sendRedirect() method of the response object and sends back the response to the browser along with the status code.  Then the browser sees the status code and look for that servlet which can now handle the request.
  • 9. sendRedirect Again the browser makes a new request, but with the name of that servlet which can now handle the request and the result will be displayed to you by the browser. In all this process the client is unaware of the processing.
  • 10. sendRedirect: Example response.sendRedirect("http://www.emer");
  • 11. forward() and sendRedirect() Click Here
  • 12. THANK YOU