This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Question from JWebPlus Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Question from JWebPlus" Watch "Question from JWebPlus" New topic
Author

Question from JWebPlus

Sushma Sharma
Ranch Hand

Joined: Jun 02, 2005
Posts: 139
Hi, this is a question from JWebPlus.

Consider the following code snippets. What will be displayed on the browser when a GET request is sent to FirstServlet assuming that the buffer is large enough to hold all the data before sending the data to the client?



Select 1 correct option.

A Only Page1 and Page3

B Only Page2

C Page1, Page2, and Page3

D IllegalStateException at Runtime.

E Compilation Error.

the answer given is D, which is also correct, but since they are askingWhat will be displayed, I think B should be correct. when a request is "forwarded" to another resource, the buffer should be cleared of the contents generated by the forwarding resource. Therefore, only Page2 will be sent to the client. Now since FirstServlet is trying to write to the response IllegalStateException will be thrown, but that does not appear at client's browser...
I have tested this using tomcat 5.0.28, is it tomcat's behaviour or all the containers behave the same?

Regards,

Sushma
Radmika Arunachalam
Ranch Hand

Joined: Mar 29, 2004
Posts: 45
I think what you said is correct!! in browser it will display "Page 2" and in the server side log file or console it will throw "IllegalStateException"..

Looks like error in JWebPlus. Since it is not freeware, is it not possible to get reply from them just curious..
S.L.Narayanan
Ranch Hand

Joined: Apr 01, 2005
Posts: 431
No. This code wont throw any IllegalStateException. Only 'Page2' will be printed and the buffer of 1st servlet will be cleared before the forward so 'Page1' wont get printed. And if u make a forward and after that if u print something to response, it will be IGNORED. it would not cause any IllegalStateException. Any objections?


SCJP 1.4, SCWCD 1.4, SCBCD 1.3, NEXT--->IBM XML
Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 950
Hi,

I agree with Narayanan.

Thanks


Narendra Dhande
SCJP 1.4,SCWCD 1.4, SCBCD 5.0, SCDJWS 5.0, SCEA 5.0
Radmika Arunachalam
Ranch Hand

Joined: Mar 29, 2004
Posts: 45
Sorry my answer is wrong.. I checked in tomcat it is not throwing ISException.. Thanks guys
Sam Sun
Ranch Hand

Joined: Feb 01, 2005
Posts: 60
Sushma, I just run that code. The result is the same as what you said.
I believe you are correct.
 
 
subject: Question from JWebPlus
 
Similar Threads
Enthuware Question ID: 1074483088830
JWebPlus Q
Clarification needed
Servlet Query
Enthuware Simulator Question (SCWCD 5)