• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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

 
Ranch Hand
Posts: 856
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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..
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 433
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Amandeep Singh
Ranch Hand
Posts: 856
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
LOOK! OVER THERE! (yoink) your tiny ad is now my tiny ad.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic