This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes RequestDipatcher Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "RequestDipatcher" Watch "RequestDipatcher" New topic
Author

RequestDipatcher

Atul Sawant
Ranch Hand

Joined: Jul 06, 2006
Posts: 304
Hello guys,

Are the following statements correct?

The execution control returns to the resource that has called the forward() method after the callee resource finishes processing.
RequestDispatcher.forward() is also a normal method call, so the control does return to the calling resource.

I thought only include() method does that, it returns the servlet and does the rest of the process.

Kindly provide your inputs.


Mission SCWCD. Mission SCJP Complete: SCJP 1.4 - 91%
Rancy Chadha
Ranch Hand

Joined: Jul 12, 2006
Posts: 135
Hi Atul,

Both include and forward calls by request dispatcher return to the calling servlet but the basic difference is that, before the forward method of the RequestDispatcher interface returns, the response content must be sent and committed, and closed by the servlet container (SRV 8.4) whereas in case of include it is not so. Therefore after forward return you cannot write anything to the output stream since it is already closed however you can do so using include.


Thanks,<br />-Rancy
Srinivasan thoyyeti
Ranch Hand

Joined: Feb 15, 2007
Posts: 557
Hi Rancy,

I would like to know...

After executing forward and getting back control
what actually the servlet can do (or) supposed to do?
[ May 16, 2007: Message edited by: Srinivasan thoyyeti ]

Thanks & Regards, T.Srinivasan
SCWCD 1.4(89%), SCJP 5.0(75%)
Rancy Chadha
Ranch Hand

Joined: Jul 12, 2006
Posts: 135
Hi Srinivasan,
After executing forward and getting back control
what actually the servlet can do (or) supposed to do?

I don't think calling servlet is supposed to do anything compulsarily after the forward call returns. But what it can do is, write to logs, write to console, set context attributes.
Srinivasan thoyyeti
Ranch Hand

Joined: Feb 15, 2007
Posts: 557
Hi Rancy,

Thank you.
Atul Sawant
Ranch Hand

Joined: Jul 06, 2006
Posts: 304
Thanks Rancy!
 
 
subject: RequestDipatcher
 
Similar Threads
RequestDispatcher forward doubt
Forward doubt
RequestDispatcher
forward and execution control
forward--RequestDispatcher