Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MIME Doubt

 
Mike Thomson
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi mike,
Please try this,
response.setContentType("APPLICATION/OCTET-STREAM");
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic