aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Which of the following statements is correct regarding a RequestDispatcher object? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Which of the following statements is correct regarding a RequestDispatcher object?" Watch "Which of the following statements is correct regarding a RequestDispatcher object?" New topic
Author

Which of the following statements is correct regarding a RequestDispatcher object?

Amandeep Singh
Ranch Hand

Joined: Jul 17, 2008
Posts: 844
A call to forward() clears the output buffer before the target resource is invoked.

A call to include() clears the output buffer before the target resource is invoked.

The execution control returns to the resource that has called the forward() method after the callee resource finishes processing.

It is not advisable for the forwarding resource to produce any output.

Both, forward() and include(), allow the caller resource to generate any amount of output.


Please do Advice...So confusing to me..


SCJP 1.4, SCWCD 5, SCBCD 5, OCPJWSD 5,SCEA-1, Started Assignment Part 2
My blog- http://rkydesigns.blogspot.com
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11486
    
  94

Please quote your sources. Many people refuse to answer questions that are unsourced, and it is not uncommon for questions to be deleted if the source is not provided (especially in the cases where the same person posts many questions without ever listing a source).

Also, you should show some effort. What answer(s) did you think were correct? What did you think was wrong? Why? It is only with this information that someone can start to provide you with help.

- Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Sunny Jain
Ranch Hand

Joined: Jul 23, 2007
Posts: 433

Call to forward( ) always clears the buffer, thats why it is always said " never flush and forward". if response is already committed before calling to forward you get the IllegalStateException

Call to include( ) doesn't clears the buffer, as include is to get inclusion of response in caller response, so I think it doesn't make any sense if it clears the buffer. for example if we want to include some footer, then we can not clear the buffer.

After forward( ), anything written to response is ignored. But I think control comes back to caller method, But we can not write anything to response. Control flow is normal java. Rules should not change for Servlets and JSP.

Yeah, Its seems correct, If forwarding request is producing any response then we get an exception. Remember : forward means complete handoff of responsibilities to another resource.

I don't understand the last point, What are you asking?


Thanks and Regards,
SCJP 1.5 (90%), SCWCD 1.5 (85%), The Jovial Java, java.util.concurrent tutorial
Joy Mukherjee
Ranch Hand

Joined: Aug 10, 2008
Posts: 62
A call to forward() clears the output buffer before the target resource is invoked.- Correct

A call to include() clears the output buffer before the target resource is invoked.- In Correct

The execution control returns to the resource that has called the forward() method after the callee resource finishes processing.- Correct

It is not advisable for the forwarding resource to produce any output.- Coorect .It will cause IllegalStateException if the output is committed before the forward.

Both, forward() and include(), allow the caller resource to generate any amount of output. - In Correct


B.Tech (E.E),IIT Kharagpur<br />SCJP 5.0<br />SCWCD 5.0<br />PMP
Amandeep Singh
Ranch Hand

Joined: Jul 17, 2008
Posts: 844
Thanks
Baddy Davay
Greenhorn

Joined: Aug 10, 2008
Posts: 26
I think the execution control does not return back to the caller servlet.When you call forward ,That means you are forwarding everything to another servlet, and the response is given by that called servlet and not the caller .
Joy Mukherjee
Ranch Hand

Joined: Aug 10, 2008
Posts: 62
Check this URL
http://www.depi.itch.edu.mx/doc/en/servlets/servlet_reqdispatcher.html

The forward call does return to the calling servlet


Thanks and Regards
Joy
 
 
subject: Which of the following statements is correct regarding a RequestDispatcher object?