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

How to find whether a parameter exists in the request object?

668


What is servlet attributes and their scope?

598


What is servlet collaboration?

668


Can you call a jsp from the servlet?

548


How the typical servlet code look like ?

639






How to get the current httpsession object?

658


What is the use of java servlet api?

603


Should I override the service() method?

671


What is the use of send redirect () method?

590


What is the functionality of actionservlet and requestprocessor?

601


Why don't we write a constructor in a servlet?

594


Explain the different ways for servlet authentication?

536


What are some disadvantages of storing session state in cookies?

593


What do you mean by session tracking and also explain its techniques?

504


What is servlet api used for conneting database?

703