File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Head First Android this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "setContentType " Watch "setContentType " New topic


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%)
I agree. Here's the link:
subject: setContentType
It's not a secret anymore!