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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "setContentType " Watch "setContentType " New topic
Author

setContentType

Ramakrishnan Ponmudi
Ranch Hand

Joined: Apr 20, 2004
Posts: 72
Is it mandatory to call setContentType before calling getWriter() or getOutputStream on response object if content type is other than "text/html". If i am not setting it, can i get any errors?
Hendy Setyo Mulyo
Ranch Hand

Joined: Dec 01, 2004
Posts: 219

There will no be error in the server. But you will not get the desired result when it displayed in the client (browser) (It will display characters in the browser). It because the browser will always assume you want to display text/html.


Hendy Setyo Mulyo
SCJP 1.4 (95%), SCWCD 1.4 (94%)
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: setContentType
 
Similar Threads
setContentType(),
setContentType
setContentType()
setContentType and getOutputStream
Using getInputStream and file upload