What is forward() and include() of servlets
RequestDispatcher interface?

Answer Posted / srilatha

Forward():

In ServletRequestDispatcher ,By using forward() method,we
can forward a request to a another resource(i.e
servlets,jsp,html....),at finally we can see only called
resource output(i.e second resource output,i.e response)
For exm. we have two servlets,(servlet1 and servlet2) we are
forwarding request from servlet1 to servlet2, in this case
we can see only servlet2 output(i.e response for the
request).
in forward()it will take only servlet1 output.
(ex: in servlet we a\are having some name like srinu with
background color blue, it will take only the name not the
color)

include():

By using include() method of RequestDispatcher we
can forward a request from servlet1 to servlet2 ,in this
case we can see both outputs(i.e servlet1 and servlet2).

in include()it will include the servlet1 page and
forwarding to the servlet2)
in this case we can see both servlet1& servlet2 as the
part of response.

Is This Answer Correct ?    15 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is Servlet API used for connecting database?

794


What is url encoding and url decoding

809


What does the term localization refer to?

763


What is the use of servlet context?

732


List out difference between a JavaBean from a Servlet?

726


Why is a constructor needed in a servlet even if we use the init method?

788


What is ServletConfig object?

802


What is the functionality of actionservlet and requestprocessor?

778


What is the process for chaining servlet?

778


What are some advantages of storing session state in cookies?

772


How is the get () method different from the post() method?

716


What is a deployment descriptor?

811


What is the difference between encodeRedirectUrl and encodeURL?

810


What is meant by session? Tell me something about httpsession class?

768


How to upload a file to the server using servlet?

718