File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Request Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Request" Watch "Request" New topic


Vallabhaneni Suresh Kumar
Ranch Hand

Joined: Mar 01, 2004
Posts: 68
What is the difference between forward() and include() methods of RequestDispatcher interface? I am not getting the clear idea. So please help me.
Adrian Pang
Ranch Hand

Joined: Feb 20, 2004
Posts: 40
I think it has to do with the control of the response. For include, the calling servlet has the control of the response. It can set the header, or status, and when the forwarded servlet is done, it can continue to write to the response. For forward, once the calling servlet forwards, it cannot write to the response anymore, and anything that it has written to the response will be cleared. In the other words, for include, the control of the response is "lend" to the other servlet, while for forward the control is "given" to the other servlet.
I hope I am right =)

SCJP 1.4, SCWCD 1.4, SCBCD 1.3
I agree. Here's the link:
subject: Request
It's not a secret anymore!