Servlet Content Type

Content Type

Also known as MIME Type, Content type’s MIME is short form of Multipurpose Internet Mail Extension. It works a HTTP header that includes various information about page like description of the package media (Images, text, video and so on)
It is sent as a HTTP protocol and exchanges response package to client.
Example: Suppose you send html text based file as a response to the client the MIME type specification-

Syntax

response.setcontentType("text/html");
There are two part of MIME Type :-:
  • Base name
  • Extension name
Base name: It is a genetic or we can say pre defined file file name.
Extension name: Extension name is name of files with specific extensions.
Following are supported Content Type by MIME
FileMIME TypeExtension
xmltext/xml..xml.
HTMLtext/html..html.
Plaintext Filetext/plain..txt.
PDFapplication/pdf..pdf.
gif Imageimage/gif..gif.
JPEG Imageimage/jpeg..jpeg.
PNG Imageimage/x-png..png.
MP3 Music Fileaudio/mpeg..mp3.
MS Word Documentapplication/msword..doc.
Excel work sheetapplication/vnd.ms-sheet..xls.
Power Point Documentapplication/vnd.ms-powerpoint..ppt.