jQuery in Action, 3rd edition
The moose likes Servlets and the fly likes RequestDispatcher Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "RequestDispatcher" Watch "RequestDispatcher" New topic


Raghavendra Holla
Ranch Hand

Joined: Jun 02, 2000
Posts: 58
Hello All,
What is the difference between RequestDispatcher's forward method and include method? In which context each can be better utilised.
Thanks in adavnce for your help.
Sagar Sharma
Ranch Hand

Joined: Aug 31, 2000
Posts: 92
forward : should be used only when u have not started replying to the client by ServletOutputStream or the PrintWriterStream.
include : can be used before or after the servlet has used either of the two mentioned above.
Also note that the resource called cannot set the headers, if it tries to do so then the result is not guaranteed.
It is sorta covered in the JavaRanch Style Guide.
subject: RequestDispatcher
jQuery in Action, 3rd edition