Servlet chaining
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Servlet chaining

on

  • 221 views

 

Statistics

Views

Total Views
221
Views on SlideShare
156
Embed Views
65

Actions

Likes
0
Downloads
4
Comments
0

2 Embeds 65

http://emertxe.wordpress.com 62
http://www.slideee.com 3

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Servlet chaining Presentation Transcript

  • 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,java.io.IOException:Forwards 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,java.io.IOException:Includes 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 txe.com");
  • 11. forward() and sendRedirect() Click Here
  • 12. THANK YOU