Hi, 'Forward' will send the original request object to the new page which means you'll see the original URL in the browser, so a refresh might look odd. You will be able to use all the parameters from the original request at the new page. 'sendRedirect()' sends a 'temporary redirect response to the client' but you must use an absolute URL.
In case of sendRedirect(), the browser issues a completely new request and any objects that are stored as request attributes before the redirect occurs, will be lost. But using jsp forward objects can be stored into the request and passed along for the next resource to make use of. Another difference is performance of forward is better than redirect since in case of a forward there is no communication with the client and the whole process occurs within the web container .
Joined: Feb 17, 2002
Thanks a lot Helen and Secl for your good explanations. I got it. One thing more...does Jsp and Servlets can share the same request. I mean are same session level varibles accessible to the servlets that were set into a Jsp page. Thanks. M.Shahzad
Joined: Jul 29, 2003
Yes it is possible. Its also possible doing the other way round, i mean you can set a session level variable from servlet and access it from jsp.