RequestDispatcher.forward() vs HttpServletResponse.sendRedirect()

前端 未结 9 807
萌比男神i
萌比男神i 2020-11-22 03:18

What is the conceptual difference between forward() and sendRedirect()?

9条回答
  •  情话喂你
    2020-11-22 03:41

    SendRedirect() will search the content between the servers. it is slow because it has to intimate the browser by sending the URL of the content. then browser will create a new request for the content within the same server or in another one.

    RquestDispatcher is for searching the content within the server i think. its the server side process and it is faster compare to the SendRedirect() method. but the thing is that it will not intimate the browser in which server it is searching the required date or content, neither it will not ask the browser to change the URL in URL tab. so it causes little inconvenience to the user.

提交回复
热议问题