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 = ... >



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


No comments yet. Be the first!

Most Viewed Articles (in Interview )

What is JSP Scriptlet?

Tell me something about J2EE component?

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

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?

What are implicit Objects available to the JSP Page?

Interview Question: How does Struts work?

What is the difference between interface and abstract class?

Differentiate between .ear, .jar and .war files.

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

Explain the user defined Exceptions?

The output of System.out.println(5>>2) in Java

Interview Question: Why are some of the class and element names counter-intuitive?

Types of Interviews

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

How to define an Interface?

Latest Articles (in Interview)