Great Deals

RequestDispatcher.forward() vs HttpServletResponse.sendRedirect()

11:19 Unknown 0 Comments

Get Free Book :)
  • RequestDispatcher.forward() vs HttpServletResponse.sendRedirect()
    _______________________________________________________________
    RequestDispatcher.forward()
    _______________________________________________________________

    1.When we use forward method, request is transfer to other resource within the same server.

    2.client or browser is not involved.

    3.When forward is called on requestdispatcher object we pass request and response objects so our old request object is passed on for further processing.

    4.ON browsers url you cant see that address.

    5. forward () method is faster then send redirect.

    _______________________________________________________________
    SendRedirect
    _________________________________________________________________
  • 1.request is transfer to another resource to different server for further processing.

  • 2.Url is visible on the browser.

  • 3.In case of sendRedirect call, old request and response objects are lost because it’s treated as new request by the browser.

  • 4.In address bar, we are able to see the new redirected address.

    5.sendRedirect is slower because one extra round trip is required, because completely new request is created and old request object is lost. Two browser request required.

  •  

 


0 comments:

Advertising