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
What are the different methods of session management in servlets?
What methods do you use in servlet - applet communication?
What is httpservlet class?
What is the requirement of servlet config and servlet context implemented and how are they implemented?
Why the container loads server at the application startup and how?
How do you configure a centralized error handler in servlets?
Explain the difference between jsp and servlet?
What is httpservlet and how it is different from genericservlet?
How do you communicate in between Applets and Servlets?
What are the two important api's in for servlets?
How can you run a servlet program?
Why do we have servlet filters?
How to read request headers from servlets?
What if we pass negative value in load-on-startup?
What is meant by Servlet? What are the parameters of service method?