What is response.sendRedirect()


This method is used to transfer the response data from one servlet to another,It is used to perform servlet navigation .sendRedirect() first, send a response to the browser then browser Instruct to redirect the assigned URL.

Here the response is the reference of the HttpServletResponse class.

sendRedirect() :-  It is the predefine method for page redirection. 

Syntax:-    response.sendRedirect("pagename||Servletname|url");

It is used to manage state of the client machine and server machine both hence we always prefer this method for navigation.

if you want to create login forms and after login redirects to dashboard then you should always prefer this method for form redirection.

If we want to redirect from the JSP web page to Servlet and Servlet to JSP or JSP to JSP or Servlet to Servlet then we prefer this method.


Post a Comment


POST Answer of Questions and ASK to Doubt

Post a Comment (0)