What is the difference between jsp:forward and response.sendRedirect(url),?.

By: Karthik Emailed: 1789 times Printed: 2624 times    

Question: What is the difference between <jsp:forward page = ... > and
response.sendRedirect(url),?.
Answer: The <jsp:forward> element forwards the request object containing the client request information from one JSP file to another file. The target file can be an HTML file, another JSP file, or a servlet, as long as it is in the same application context as the forwarding JSP file. 
sendRedirect sends HTTP temporary redirect response to the browser, and browser creates a new request to go the redirected page. The  response.sendRedirect kills the session variables.

Most Viewed Articles (in Interview )

Latest Articles (in Interview)

Comment on this tutorial