aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes 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 "regarding a RequestDispatcher object" Watch "regarding a RequestDispatcher object" New topic
Author

regarding a RequestDispatcher object

Poonam Agarwal
Ranch Hand

Joined: May 12, 2008
Posts: 323
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


Thanks <br />Poonam Agarwal SCWCD 86%
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3860

Please QuoteYourSources


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Poonam Agarwal
Ranch Hand

Joined: May 12, 2008
Posts: 323
this question from Enthuware mock engine.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

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

Joined: May 12, 2008
Posts: 323
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

Joined: Jan 28, 2008
Posts: 5575

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

Joined: May 12, 2008
Posts: 323
I won't be able to seen the system.out after calling request.sendRedirect().


Please check if i am wrong
nisha chidella
Ranch Hand

Joined: Jul 24, 2008
Posts: 57
you can see that in the log.


SCJP 5.0(100%)
Preparing for SCWCD
Poonam Agarwal
Ranch Hand

Joined: May 12, 2008
Posts: 323
not in the client brower window??? Right ?
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3860

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

Joined: May 12, 2008
Posts: 323
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

Joined: Mar 24, 2008
Posts: 3860

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

Joined: May 12, 2008
Posts: 323
thanks Vijitha, thank you very much to clear my horriable doubt.


Thnaks dear
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: regarding a RequestDispatcher object