• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

regarding a RequestDispatcher object

 
Poonam Agarwal
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which of the following statements is correct regarding a RequestDispatcher object?

A. A call to forward() clears the output buffer before the target resource is invoked.
B. A call to include() clears the output buffer before the target resource is invoked.
C. The execution control returns to the resource that has called the forward() method after the callee resource finishes processing.
D. It is not advisable for the forwarding resource to produce any output.
E. Both, forward() and include(), allow the caller resource to generate any amount of output.

the correct option are A,C,D
I dont understand how can C include in the correct options. As per HFSJ chapter no 4, page no 139,
when a servlet does a request dispatch, its like asking a co-worker to take over working with the client. The co-worker ends up responding to a client. but the client doesn't care as long as some respnds.


how can a execution contral then returns to the resource that called the forward() method. As I understand forward recource itself comitted the response by sending appropriate reply.

Please correct me If i am wrong

Thanks In Advance
 
Vijitha Kumara
Bartender
Posts: 3913
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please QuoteYourSources
 
Poonam Agarwal
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this question from Enthuware mock engine.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Poonam Agarwal wrote:
I dont understand how can C include in the correct options.


it is ordinary java method behaviour.if you call one method(say A) from another method(say B),after the called method(A) . the controll will return to calling method(B) right?..

test yourself with this example
 
Poonam Agarwal
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
test yourself with this example


yes I did and find option C is correct.
But still I have this confusion actualy I have read some where about this behaviour. I wonder if this particular behaviour won't be available for response.sendRedirect().
If I can properly collect it it says
No further output to the client should be made by the servlet after these methods are called. If data is written to the response after this method are called, the data is ignored.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Poonam Agarwal wrote:
No further output to the client should be made by the servlet after these methods are called. If data is written to the response after this method are called, the data is ignored.


yes. but Infact you are misunderstanding the above statement .


just place above code into the TestServlet and watch the server console
 
Poonam Agarwal
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I won't be able to seen the system.out after calling request.sendRedirect().


Please check if i am wrong
 
nisha chidella
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can see that in the log.
 
Poonam Agarwal
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
not in the client brower window??? Right ?
 
Vijitha Kumara
Bartender
Posts: 3913
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Poonam Agarwal wrote:not in the client brower window??? Right ?


No. The output from



will go into the log file your application server uses to store the console output.
 
Poonam Agarwal
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello Vijitha,

i am really getting confused badly

If data is written to the response after this method are called, the data is ignored.
what does this mean then??

Please help

 
Vijitha Kumara
Bartender
Posts: 3913
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Poonam Agarwal wrote:If data is written to the response after this method are called, the data is ignored.
what does this mean then??


That is data is ignored for the response. (i.e: Nothing after the method call will be written in to the response).
 
Poonam Agarwal
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Vijitha, thank you very much to clear my horriable doubt.


Thnaks dear
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic