• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Amandeep Singh
Ranch Hand
Posts: 850
  • Mark post as helpful
  • send pies
  • 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..
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • 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
 
Deepak Chopra
Ranch Hand
Posts: 433
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • 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?
 
Joy Mukherjee
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • 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: 850
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
 
Baddy Davay
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic