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

By: Karthik 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 )

What are all the different scope values for the tag?

Interview Question: What is ActionServlet?

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

Interview Question: What is the difference between sessioncontext and entitycontext?

Interview Question: Is Decorator an EJB design pattern?

Interview Question: Can i map more than one table in a CMP?

Interview Question: What is abstract schema?

Interview Question: What is the difference between find and select methods in EJB?

Interview Question: Is it possible to share an HttpSession between a JSP and EJB? What happens when I change a value in the HttpSession from inside an EJB?

Question: Difference between forward and sendRedirect in JSP?

Question: What is an Expression tag in JSP?

Question: Explain the life-cycle methods in JSP?

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

Question: How is the MVC design pattern used in Struts framework?

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

Latest Articles (in Interview)

Comment on this tutorial