JSP Interview Questions and Answers
<< Previous Question Next Question >>
 Question: 300 Page Views: 

What's the difference between forward and sendRedirect?



Posted By: Avi Date: 6 November 2010 04:35:56 AM
 Answer:

forward is server side redirect; when it is invoked, the request is sent to another resource on the server, without the client being informed that a different resource is going to process the request and this process occurs completely with in the web container and then returns to the calling method sendRedirect is client side redirect; when is invoked, it causes the web container to return to the browser indicating that a new URL should be requested. Because the browser issues a completely new request any object that are stored as request attributes before the redirect occurs will be lost. So redirect is slower than forward.


Posted By: avibtech


Date: 6 November 2010 04:35:56 AM
Post a better Answer if you have
 
(Will show your Gravatar icon)  
  Country flag

Loading
Enter the text as shown in the image VOGj0u
Related Questions
JSP : Can Runnable interface be implemented from within the servlet?

Can Runnable interface be implemented from within the servlet?

Yes
Category: JSP Date: 11/2/2010 10:05:59 PM
JSP : How can you print the stack trace of an exception from a  JSP page?

How can you print the stack trace of an exception from a  JSP page?

By creating an object of PrintWriter we can print the stack trace in JSP page. Eg: PrintWriter pw = ....
Category: JSP Date: 11/2/2010 9:32:59 PM
JSP : Is inter servlet communication important?

Is inter servlet communication important?

Yes, and that because of : 1: Direct servlet manipulation allows to gain access to the other curren....
Category: JSP Date: 11/2/2010 8:26:57 PM
JSP : What is a Java Bean?

What is a Java Bean?

A Java Bean is a software component that has been designed to be reusable in a variety of different ....
Category: JSP Date: 11/2/2010 6:05:58 PM
JSP : How does JSP handle runtime exceptions?

How does JSP handle runtime exceptions?

By using errorPage attribute of page directive JSP handles runtime exceptions and set isErrorPage = ....
Category: JSP Date: 11/2/2010 5:32:57 PM