wood burning stoves 2.0*
The moose likes Servlets and the fly likes Regarding response.setContentType Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Regarding response.setContentType" Watch "Regarding response.setContentType" New topic
Author

Regarding response.setContentType

Sriram Sharma
Ranch Hand

Joined: Apr 12, 2006
Posts: 97
What would happen if we dont specify response.setContentType("text/html"); ?
Can we survive without this setter in servlets?

Regards,
Sriram
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 684


Hi,

Yes you can survive without declaring response.setContentType("text/html"); but what if you want to send some other format in response like video or other format. There is always default value. response.setContentType basically use to browser get idea what kind of response send by server.


Thanks, Nishan Patel
SCJP 1.5, SCWCD 1.5, OCPJWSD Java Developer,My Blog
 
 
subject: Regarding response.setContentType
 
Similar Threads
response.setContentType("application/vnd.ms-excel");
why should we set response.setContentType before using PrintWriter or OutputStream?
How to output JSP page to Excel ?
Using response.setcontenttype
How to respond to the client in PDF format to the client from Servlet?