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
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Reply 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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: setContentType
 
Similar Threads
HFJS (V2) Final Mock Question 45 is wrong?
how to return http response without creating html output
doubt in flush method
Difference between PrintWriter and Output Stream.
Tomcat 6 Servlet getting error: Not an ISO 8859-1 character