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

By: Karthik Viewed: 396 times  Printer Friendly Format    


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 )

Question: Explain the life-cycle methods in JSP?

What is the difference between JTS and JTA?

Name the containers which uses Border Layout as their default layout?

Question: What is the directory structure of a web application?

Interview Question: What is ActionServlet?

Interview Question: What are the optional clauses in EJB QL?

Interview Question: What is the difference between ejbCreate() and ejbPostCreate?

Interview Question: What is difference between EJB 1.1 and EJB 2.0?

Interview Question: What is lazy loading?

Interview Question: What is deployment descriptor?

Question: Difference between forward and sendRedirect in JSP?

Question: What is an Expression tag in JSP?

Question: How would you go about analyzing performance of an application?

What is bean managed transaction?

How to define an Abstract class?

Latest Articles (in Interview)

Comment on this tutorial