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 )

Interview Question: Do you have to credit Struts on your own website?

What is Deployment Descriptor?

What is similarities/difference between an Abstract class and Interface?

Interview Question: What is Action Class?

Interview Question: What is ActionServlet?

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

Interview Question: What is re-entrant. Is session beans reentrant. Is entity beans reentrant?

Interview Question: What is the difference between JavaBean and EJB?

Question: What is a Hidden Comment in JSP?

Why J2EE is suitable for the development distributed multi-tiered enterprise applications?

What is J2EE Connector architecture?

What types of comments are available in the JSP?

Interview Question: Why it is called Struts?

Interview Question: Is there a particularly good IDE to use with Struts ?

Interview Question: What is the difference between EAR, JAR and WAR file?

Latest Articles (in Interview)

Comment on this tutorial