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

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

653


What is servlet container?

651


Can filter be used as request or response?

534


What is the difference between Servlets and Applets?

535


what is servlet chaining?

615






Tell the new features added in servletrequest interface i.e. Servlet 2.4

563


What are different methods of session management in servlets?

768


What do you mean by httpservlet and how it is different from the genericservlet?

530


What is java servlet session?

515


Elucidate servlet attributes and its scope?

558


What do you mean by filter in servlet?

528


Why jsp is better than servlet?

524


What methodology can be followed to store more number of objects in a remote server?

1807


Can servlet have a constructor ?

585


Who is responsible to create the object of servlet?

704