Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet Response

 
Shobhan Ganta
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For a given ServletResponse response, which two retrieve an object for writing text data?
(Choose two.)
A. response.getWriter()
B. response.getOutputStream()
C. response.getOutputWriter()
D. response.getWriter().getOutputStream()
E. response.getWriter(Writer.OUTPUT_TEXT)


Answer: A, B

Shouldn't it be just A?

Thanks
Shobhan
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2536
113
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Shobhan,

Please QuoteYourSources

Regards,
Frits
 
Gaurav Sagar
Ranch Hand
Posts: 97
Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shobhan Ganta wrote:
For a given ServletResponse response, which two retrieve an object for writing text data?
(Choose two.)
A. response.getWriter()
B. response.getOutputStream()
C. response.getOutputWriter()
D. response.getWriter().getOutputStream()
E. response.getWriter(Writer.OUTPUT_TEXT)


Answer: A, B

Shouldn't it be just A?

Thanks
Shobhan


No, it has to be both A and B, with the getOutputStream() you get an object of ServletOutputStream which could be used to write text data by chaining a say, DataOutputStream about it.

Furthermore, the getWriter() gives you a PrintWriter object which is chained to this ServletOutputStream behind the scenes. So, in the end its just the ServletOutputStream that is used to write data( byte/text).

Regards,
Gaurav
 
Shobhan Ganta
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Gaurav.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic