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 )

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

Is Iterator a Class or Interface? What is its use?

Types of Interviews

Getting started with Interview

Interview Question: What is the difference between Message Driven Beans and Stateless Session beans?

What is transient variable?

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

Interview Question: What is abstract schema?

Explain the user defined Exceptions?

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

Interview Question: Why does EJB needs two interfaces(Home and Remote Interface)?

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

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

How to define an Interface?

Question: Difference between forward and sendRedirect in JSP?

Latest Articles (in Interview)