sendRedirect « Request « JSP-Servlet Q&A

1. sendRedirect or request Dispatch is more efficient?

SendRedirect or requestdispatch ?Which should be more preferred?Which is more efficient?

2. request.sendRedirect or javascript: document.location.replace()

sendRedirect is more effiecient than the JavaScript exmple. The JavaScript example requires that the entire page load before the redirect occurs. sendRedirect only returns an http header code for Redirect. The initially requested page never loads in the browser. sendRedirect is a method in HttpServletResponse which you have available in a JSP page. As long as you follow the rules and ...