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
How can we invoke another servlet in a different application?
What are the key methods that are involved in processing of http servlets?
What are the drawbacks of cgi?
Explain the steps involved in placing a servlet within a package?
Why do we have servlet filters?
Which are the different ways you can communicate between servlets?
What is the use of attribute in servlets?
Why doesn’t a servlet include main()? How does it work?
Can a jsp be called using a servlet?
What are the life cycle methods of the servlet?
Define the lifecycle for executing a jsp page.
What is the servletconfig object?
Name the different ways of session tracking.
How do you invoke a servelt?
When to use doget() and when dopost()?