For a given Servlet Response response, which retrieves an object for writing binary data? (Choose two) A. response.getWriter () B. response.getOutputStream () C. response.getOutputWriter() D. response.getWriter().getOutputStream() E. response.getWriter(Writer.OUTPUT_BINARY)
A, B are the answers given. But how can PrintWriter used to write binary data? (my java io knowledge is a bit limited)
The write() method of PrintWriter does accept char or int - but not byte/byte. Does that mean we cannot send arbitrary bytes to the stream?
Hi Alec, where did this question come from? I don't understand how A and B could be right. Every book or web page I read about writing binary data from a servlet they emphasize that we should use the getOutputStream() and this should also be the answer for certification questions. Are you sure the answers are right? I mean, I was pretty sure about that, now I think that I know nothing about servlets
Joined: Jan 28, 2004
A TK question which means ..... we could face it in real life