What is difference between Forward() and sendRedirect()
methode?

Answer Posted / farhaananwar

Foward action is done at server site without interference of
web browser even the old URL is not changed whereas request
is forwarded to new resource hence forward action is faster
than redirect action. when forward operation is performed
request attributes and session attributes persists.
In case of redirection. servlet container sends the
response to clien web browser by setting status to
HttpServletRequest.SC_TEMPORARY_REDIRECT and location header
to the new URL address where browser will have to redirect
new request automattically without interference of client.
when browser redirect new request to resource, the URL in
web browser changed. This proccess is slower than forward
because server send response to browser telling that
resource requested is moved temporary to other resource and
need redirction and then browser take action. The request
paramters are persist in new redirect request.

Is This Answer Correct ?    1 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the need of servlet filters?

542


What are the benefits of using servlet over cgi?

582


Explain url encoding?

522


Elucidate servlet attributes and its scope?

571


What is the use of welcome-file-list?

576






Explain load on start-up and its importance?

601


How can the session in servlet be destroyed?

646


What are the mechanisms used by a servlet container for maintaining session information?

570


Which java application server is the best?

551


How do you load an image in a Servlet?

662


What are the jobs performed by servlets?

585


Differentiate between the web server and application server?

565


Is servlet a server side scripting language?

555


What are the difference between RMI and Servlets?

1054


What is the capacity the doget can send to the server?

578