sendRedirect() and forward() methods are applicable to both servlets and jsp in java. Since jsp converts to a servlet itself, these methods can be used inside a scriplet in a jsp.
sendRedirect():
This method is called from HttpServletResponse object. This method from response object expects an URL where the response is required to redirect. This sends the user to different location located on a different server altogether. This happens on a client side or browser. The new address will be visible in the browser.
Redirect sets the response status to 302, and the new url in a Location header, and sends the response to the browser. Then the browser, according to the http specification, makes another request to the new url.
sendRedirect():
This method is called from HttpServletResponse object. This method from response object expects an URL where the response is required to redirect. This sends the user to different location located on a different server altogether. This happens on a client side or browser. The new address will be visible in the browser.
Redirect sets the response status to 302, and the new url in a Location header, and sends the response to the browser. Then the browser, according to the http specification, makes another request to the new url.