File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes setContentType Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "setContentType" Watch "setContentType" New topic
Author

setContentType

Ranjani Theyagarajan
Greenhorn

Joined: Feb 08, 2006
Posts: 19
response.setContentType("image/gif");

// insert code here...

out.close()

which statement will intialize the out variable?

a) PrintWriter out=response.getWriter();
b) PrintWriter out=response.GetOutputStream();
c) OutputStream out=response.getOutputStream();
d) ServletOutputStream out=response.getServletOutput();


My answer is C. but the given answer is a.
I read somewhere that for binary data need to use getOutPutStream.
Please correct me if am wrong

Thanks,
Ranjani
Patrick Williams
Ranch Hand

Joined: Apr 03, 2005
Posts: 213
What is the source of this question (mock exam?)? I agree that C should be the answer given that you are setting the content type to be an image.


Patrick<br /> <br />SCJP/SCWCD/SCBCD/SCDJWS/SCEA<br /> <br />Currently working on:<br />SCJP 6
Ranjani Theyagarajan
Greenhorn

Joined: Feb 08, 2006
Posts: 19
Thanks Patrick... I got a PDF from my friend which contains this one..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: setContentType