I have an application which can uplodad any type of files with whaever formats/extensions like .doc,.zip,.ppt,.pdf,.txt... I am storing this files in the db using blob and also I can able to retrieve the fiel from db to the local disk. I have written a servlet which can read the file from the local disk. But I don't know how to set the setContentType for different extensions. Whether I have to set the contentType differently for different file types or any other way to do it. For example: Below code is for word document to be read:
For .ppt / .txt / .pdf, whether I have to change the contentType or some any common contentType is available for use
mani vannann
Greenhorn
Joined: Nov 27, 2007
Posts: 3
posted
0
Hi mike, Please try this, response.setContentType("APPLICATION/OCTET-STREAM");
See ServletContext.getMimeType which will give you access to the same mechanism that the container uses to set mime types by file extension when it serves up static files.