File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Good Quesion

 
Deepak Jain
Ranch Hand
Posts: 637
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Explanation
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
Posts: 476
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Would that be an IllegalStateException?
 
Nishit Zaveri
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 2851
10
Fedora Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .
 
Praveen Kumar
Ranch Hand
Posts: 133
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Very good question !!

Thanks for posting !!
 
raja ram
Ranch Hand
Posts: 169
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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.

Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic