wood burning stoves 2.0
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Good Quesion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Good Quesion" Watch "Good Quesion" New topic

Good Quesion

Deepak Jain
Ranch Hand

Joined: Aug 05, 2006
Posts: 637

a It will print Hello World in the output.
b It will generate compile-time errors.
c It will throw runtime exceptions.
d It will only print Hello.
e None of above.
Answer: c
As explained in chapter 4, �The Servlet model,� the OutputStream of a response object is used for sending binary data to the client while the Writer object is used for sending character data. However, we cannot use both on the same response object. Since the JSP engine automatically gets the JspWriter from the response object to output the content of the JSP as character data, the call to getOutputStream() throws a java.lang.IllegalStateException. Thus,the correct answer is c.

SCWCD Exam Study Kit : Hanumanth Deshmukh

Its a nice question.

Anton Golovin
Ranch Hand

Joined: Jul 02, 2004
Posts: 476
Would that be an IllegalStateException?

Anton Golovin (anton.golovin@gmail.com) SCJP, SCJD, SCBCD, SCWCD, OCEJWSD, SCEA/OCMJEA [JEE certs from Sun/Oracle]
Nishit Zaveri

Joined: Oct 07, 2008
Posts: 14
Since JSP always get translated into Servlet first, in this case at the time of Servlet class compilation it will be having two streams (character stream by default and explicitly created byte stream in code) then it should throw compile time error (2nd option) why it's giving runtime error?

Amit Ghorpade

Joined: Jun 06, 2007
Posts: 2851

Please make sure that you use real words for your posts."Quesion" in place of question makes the post highly unreadable.

Also consider making your subject line more descriptive. Read this to know why this is important. You can edit your post by clicking the .

|Asking Good Questions|
Praveen Kumar
Ranch Hand

Joined: Nov 06, 2006
Posts: 133
Very good question !!

Thanks for posting !!
raja ram
Ranch Hand

Joined: Mar 02, 2008
Posts: 169

Jsp gets Implicit Object out which is a Character writer,We cant call OutPutStream for binary data
Operation it will give translation Error saying "OutPutStream already called" so.

will give translation time error.However

Will work but output cant be determined correctly because we have two different buffers now.

I agree. Here's the link: http://aspose.com/file-tools
subject: Good Quesion
It's not a secret anymore!