Difference between Include, Forward and sendRedirect in
Servlet?

Answer Posted / samit katiyar

forward() should be called before the response has been
committed to the client (before response body output has
been flushed). If the response already has been committed,
this method throws an IllegalStateException. Uncommitted
output in the response buffer is automatically cleared
before the forward.

While with include()...... The request and response
parameters must be either the same objects as were passed
to the calling servlet's service method or be subclasses of
the ServletRequestWrapper or ServletResponseWrapper classes
that wrap them.

Is This Answer Correct ?    8 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why do we have servlet listeners?

777


What is ServletContext object?

817


Explain request dispatcher and its methods.

753


When should you prefer to use doget() over dopost()?

824


What is a generic servlet?

675


What are the differences between forward() method and sendredirect() methods?

737


What are the objects involved when a servlet receives a call from client?

733


What is context in servlet?

734


What is URL Encoding?

819


Define context initialization parameters.

771


Differentiate between the print writer and servlet output stream?

732


What is the use of servlet context?

729


If some new data has entered the database, explain how can a servlet refresh automatically?

955


What are the jobs performed by servlets?

756


Why are servlets used?

712