Programming Tutorials

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

By: Karthik in Interview Tutorials on 2012-06-16  

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.






Add Comment

* Required information
1000

Comments

No comments yet. Be the first!

Most Viewed Articles (in Interview )

What is transient variable?

What is the difference between interface and abstract class?

Interview Question: Do ActionForms have to be true JavaBeans?

What are the call back methods in Session bean?

What is the difference between Session Bean and Entity Bean?

Question: What is an Expression tag in JSP?

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

Interview Question: What is EJB container?

Interview Question: What is Local client view in EJB?

What is difference between Java Bean and Enterprise Java Bean?

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

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

What is bean managed transaction?

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

Interview Question: What are the call back methods in Entity bean?

Latest Articles (in Interview)