response.sendRedirect("sd.jsp");
out.println("hello");
RequestDispatcher rd=request.getRequestDispatcher("sd.jsp");
rd.include(request,response);
out.println("hello");
Hai what is happening internally when executing those two snippets in two different jsp
RequestDispatcher.forward() works on the server and response.sendRedirect() works on the browser.
When you invoke RequestDispatcher.forward(), the servlet engine transfers control of this HTTP request internally from your current servlet or JSP to another servlet or JSP or static file.
When you invoke response.sendRedirect(), this sends an HTTP response to the browser to make another request at a different URL.