What is the difference between forward() and include() methods of RequestDispatcher interface? I am not getting the clear idea. So please help me.
posted 12 years ago
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 =) Adrian