Response. setContentType () and MIME Parameters

Source: Internet
Author: User
Tags dbx fdf pkcs12 pkcs7 rfc822 framemaker

Response. setContentType (MIME) is used to enable the client browser to differentiate different types of data and call different program embedding modules in the browser to process the corresponding data according to different MIME types.

For example, a web browser uses the MIME type to determine whether a file is a GIF image. The MIME type is used to process json strings.
The installation directory \ conf \ web. xml of Tomcat defines a large number of MIME types. For details, refer.
Response. setContentType ("text/html; charset = UTF-8"); html
. SetContentType ("text/plain; charset = UTF-8"); text
Text/javascript json data
Application/xml data

This method sets the content type of the response sent to the client. At this time, the response has not been submitted. The given content type can include character encoding instructions, such as: text/html; charset = UTF-8. if this method is called before the getWriter () method is called, the character encoding of the response is set only from the given content type. If this method is called after the getWriter () method is called or after the method is submitted, no response character encoding is set. When http is used, this method sets the Content-type object header.

Generally, in Servlet, it is customary to first set the request and response content types and encoding methods:Copy codeThe Code is as follows: response. setContentType ("text/html; charset = UTF-8 ");
Request. setCharacterEncoding ("UTF-8 ");
String parameter of response. setContentType () and corresponding type
<Option value = "image/bmp"> BMP </option>
<Option value = "image/gif"> GIF </option>
<Option value = "image/jpeg"> JPEG </option>
<Option value = "image/tiff"> TIFF </option>
<Option value = "image/x-dcx"> DCX </option>
<Option value = "image/x-pcx"> PCX </option>
<Option value = "text/html"> HTML </option>
<Option value = "text/plain"> TXT </option>
<Option value = "text/xml"> XML </option>
<Option value = "application/afp"> AFP </option>
<Option value = "application/pdf"> PDF </option>
<Option value = "application/rtf"> RTF </option>
<Option value = "application/msword"> MSWORD </option>
<Option value = "application/vnd. ms-excel"> MSEXCEL </option>
<Option value = "application/vnd. ms-powerpoint"> MSPOWERPOINT </option>
<Option value = "application/wordperfect5.1"> WORDPERFECT </option>
<Option value = "application/vnd. lotus-wordpro"> WORDPRO </option>
<Option value = "application/vnd. visio"> VISIO </option>
<Option value = "application/vnd. framemaker"> FRAMEMAKER </option>
<Option value = "application/vnd. lotus-1-2-3"> lotus 123 </option>

The MIME ing policy is the application (plug-in) used in the webpage and the file to open. In addition, permission issues exist. For example, the "application/PDF" policy is used for pdf documents. This is common in dynamic web pages. There are two scenarios for this: one is to use an application to open a document that cannot be opened. For example, to define a "DWG" document in a tag, use "application/pdf ", the problem cannot be opened. Second, the file extension meets the requirements, but the file content (Format) does not. You can check the source code of your web page to obtain error information. The check method is: view-source file. Search for a string similar to "application/pdf" and you can see whether the file to be opened matches the application. The answer is usually changed by the webpage author if the answer is not matched. For example, you can find the HTML tag of the file you want to open in the source file and add an application to it. For example, you need to open a PDF document on the webpage, find the line of the PDF document, and add type = "application/pdf" to the HTML Tag. For example, the following HTML file: <! ---------- Test MIME -----------> Bytes -------------------------------------------------------------------------------------------------------------
Response. setContentType () parameter descriptionCopy codeThe Code is as follows: <meta http-equiv = "Content-Type" content = "text/html; charset = GBK">
Response. setContentType ();
* = Application/octet-stream
. 001 = application/x-001
. 301 = application/x-301
. 323 = text/h323
. 906 = application/x-906
. 907 = drawing/907
. A11 = application/x-a11
. Acp = audio/x-mei-aac
. Ai = application/postscript
. Aif = audio/aiff
. Aifc = audio/aiff
. Aiff = audio/aiff
. Anv = application/x-anv
. Asa = text/asa
. Asf = video/x-ms-asf
. Asp = text/asp
. Asx = video/x-ms-asf
. Au = audio/basic
. Avi = video/avi
. Awf = application/vnd. adobe. workflow
. Biz = text/xml
. Bmp = application/x-bmp
. Bot = application/x-bot
. C4t = application/x-c4t
. C90 = application/x-c90
. Cal = application/x-cals
. Cat = application/vnd. ms-pki.seccat
. Cdf = application/x-netcdf
. Cdr = application/x-cdr
. Cel = application/x-cel
. Cer = application/x-x509-ca-cert
. Cg4 = application/x-g4
. Cgm = application/x-cgm
. Cit = application/x-cit
. Class = java /*
. CRF = text/xml: the client browser parses the document in XML format.
. Cmp = application/x-cmp
. Cmx = application/x-cmx
. Cot = application/x-cot
. Crl = application/pkix-crl
. Crt = application/x-x509-ca-cert
. Csi = application/x-csi
. Css = text/css: the client browser parses the document in CSS format.
. Cut = application/x-cut
. Dbf = application/x-dbf
. Dbm = application/x-dbm
. Dbx = application/x-dbx
. Dcd = text/xml: the client browser parses the document in XML format.
. Dcx = application/x-dcx
. Der = application/x-x509-ca-cert
. Dgn = application/x-dgn
. Dib = application/x-dib
. Dll = application/x-msdownload
. Doc = application/msword
. Dot = application/msword
. Drw = application/x-drw
. Dtd = text/xml: the client browser parses the document in XML format.
. Dwf = Model/vnd. dwf
. Dwf = application/x-dwf
. Dwg = application/x-dwg
. Dxb = application/x-dxb
. Dxf = application/x-dxf
. Edn = application/vnd. adobe. edn
. Emf = application/x-emf
. Eml = message/rfc822
. Ent = text/xml: the client browser parses the document in XML format.
. Epi = application/x-epi
. Eps = application/x-ps
. Eps = application/postscript
. Etd = application/x-ebx
. Exe = application/x-msdownload
. Fax = image/fax
. Fdf = application/vnd. fdf
. Fif = application/fractals
. Fo = text/xml: the client browser parses the document in XML format.
. Frm = application/x-frm
. G4 = application/x-g4
. Gbr = application/x-gbr
. Gcd = application/x-gcd
. Gif = image/gif
. Gl2 = application/x-gl2
. Gp4 = application/x-gp4
. Hgl = application/x-hgl
. Hmr = application/x-hmr
. Hpg = application/x-hpgl
. Hpl = application/x-hpl
. Hqx = application/mac-binhex40
. Hrf = application/x-hrf
. Hta = application/hta
. Htc = text/x-component
. Htm = text/html: the client browser parses documents in hypertext format.
. Html = text/html: the client browser parses documents in hypertext format.
. Htt = text/webviewhtml
. Htx = text/html: the client browser parses documents in hypertext format.
. Icb = application/x-icb
. Ico = image/x-icon
. Ico = application/x-ico
. Iff = application/x-iff
. Ig4 = application/x-g4
. Ig = application/x-ig
. Iii = application/x-iphone
. Img = application/x-img
. Ins = application/x-internet-signup
. Isp = application/x-internet-signup
. IVF = video/x-ivf
. Java = java /*
. Jfif = image/jpeg
. Jpe = image/jpeg
. Jpe = application/x-jpe
. Jpeg = image/jpeg
. Jpg = image/jpeg
. Jpg = application/x-jpg
. Js = application/x-javascript
. Jsp = text/html: the client browser parses documents in hypertext format.
. La1 = audio/x-liquid-file
. Lar = application/x-laplayer-reg
. Latex = application/x-latex
. Lavs = audio/x-liquid-secure
. Lbm = application/x-lbm
. Lmsff = audio/x-la-lms
. Ls = application/x-javascript
. Ltr = application/x-ltr
. M1v = video/x-mpeg
. M2v = video/x-mpeg
. M3u = audio/mpegurl
. M4e = video/mpeg4
. Mac = application/x-mac
. Man = application/x-troff-man
. Math = text/xml
. Mdb = application/msaccess
. Mdb = application/x-mdb
. Mfp = application/x-shockwave-flash
. Mht = message/rfc822
. Mhtml = message/rfc822
. Mi = application/x-mi
. Mid = audio/mid
. Midi = audio/mid
. Mil = application/x-mil
. Mml = text/xml
. Mnd = audio/x-musicnet-download
. Mns = audio/x-musicnet-stream
. Mocha = application/x-javascript
. Movie = video/x-sgi-movie
. Mp1 = audio/mp1
. Mp2 = audio/mp2
. Mp2v = video/mpeg
. Mp3 = audio/mp3
. Mp4 = video/mpeg4
. Mpa = video/x-mpg
. Mpd = application/vnd. ms-project
. Mpe = video/x-mpeg
. Mpeg = video/mpg
. Mpg = video/mpg
. Mpga = audio/rn-mpeg
. Mpp = application/vnd. ms-project
. Mps = video/x-mpeg
. Mpt = application/vnd. ms-project
. Mpv = video/mpg
. Mpv2 = video/mpeg
. Mpw = application/vnd. ms-project
. Mpx = application/vnd. ms-project
. CTX = text/xml
. Mxp = application/x-mmxp
. Net = image/pnetvue
. Nrf = application/x-nrf
. Nws = message/rfc822
. Odc = text/x-ms-odc
. Out = application/x-out
. P10 = application/pkcs10
. P12 = application/x-pkcs12
. P7b = application/x-pkcs7-certificates
. P7c = application/pkcs7-mime
. P7m = application/pkcs7-mime
. P7r = application/x-pkcs7-certreqresp
. P7s = application/pkcs7-signature
. Pc5 = application/x-pc5
. Pci = application/x-pci
. Pcl = application/x-pcl
. Pcx = application/x-pcx
. Pdf = application/pdf: the client browser parses the document in PDF format.
. Pdf = application/pdf
. Pdx = application/vnd. adobe. pdx
. Pfx = application/x-pkcs12
. Pgl = application/x-pgl
. Pic = application/x-pic
. Pko = application/vnd. ms-pki.pko
. Pl = application/x-perl
. Plg = text/html
. Pls = audio/scpls
. Plt = application/x-plt
. Png = image/png
. Png = application/x-png
. Pot = application/vnd. ms-powerpoint
. Ppa = application/vnd. ms-powerpoint
. Ppm = application/x-ppm
. Pps = application/vnd. ms-powerpoint
. Ppt = application/vnd. ms-powerpoint
. Ppt = application/x-ppt
. Pr = application/x-pr
. Prf = application/pics-rules
. Prn = application/x-prn
. Prt = application/x-prt
. Ps = application/x-ps
. Ps = application/postscript
. Ptn = application/x-ptn
. Pwz = application/vnd. ms-powerpoint
. R3t = text/vnd. rn-realtext3d
. Ra = audio/vnd. rn-realaudio
. Ram = audio/x-pn-realaudio
. Ras = application/x-ras
. Rat = application/rat-file
. Rdf = text/xml
. Rec = application/vnd. rn-recording
. Red = application/x-red
. Rgb = application/x-rgb
. Rjs = application/vnd. rn-realsystem-rjs
. Rjt = application/vnd. rn-realsystem-rjt
. Rlc = application/x-rlc
. Rle = application/x-rle
. Rm = application/vnd. rn-realmedia
. Rmf = application/vnd. adobe. rmf
. Rmi = audio/mid
. Rmj = application/vnd. rn-realsystem-rmj
. Rmm = audio/x-pn-realaudio
. Rmp = application/vnd. rn-rn_music_package
. Rms = application/vnd. rn-realmedia-secure
. Rmvb = application/vnd. rn-realmedia-vbr
. Rmx = application/vnd. rn-realsystem-rmx
. Rnx = application/vnd. rn-realplayer
. Rp = image/vnd. rn-realpix
. Rpm = audio/x-pn-realaudio-plugin
. Rsml = application/vnd. rn-rsml
. Rt = text/vnd. rn-realtext
. Rtf = application/msword
. Rtf = application/x-rtf
. Rv = video/vnd. rn-realvideo
. Sam = application/x-sam
. Sat = application/x-sat
. Sdp = application/sdp
. Sdw = application/x-sdw
. Sit = application/x-stuffit
. Slb = application/x-slb
. Sld = application/x-sld
. Slk = drawing/x-slk
. Smi = application/smil
. Smil = application/smil
. Smk = application/x-smk
. Snd = audio/basic
. Sol = text/plain
. Sor = text/plain
. Spc = application/x-pkcs7-certificates
. Spl = application/futuresplash
. Spp = text/xml
. Ssm = application/streamingmedia
. Sst = application/vnd. ms-pki.certstore
. Stl = application/vnd. ms-pki.stl
. Stm = text/html
. Sty = application/x-sty
. Svg = text/xml
. Swf = application/x-shockwave-flash: the client browser parses the document in Flash format.
. Tdf = application/x-tdf
. Tg4 = application/x-tg4
. Tga = application/x-tga
. Tif = image/tiff
. Tif = application/x-tif
. Tiff = image/tiff
. Tld = text/xml
. Top = drawing/x-top
. Torrent = application/x-bittorrent
. Tsd = text/xml
. Txt = text/plain: the client browser parses the document in plain text format.
. Uin = application/x-icq
. Uls = text/iuls
. Vcf = text/x-vcard
. Vda = application/x-vda
. Vdx = application/vnd. visio
. Vml = text/xml
. Vpg = application/x-vpeg005
. ASD = application/vnd. visio
. Sealing Method = application/x-Sealing Method
. Vss = application/vnd. visio
. Vst = application/vnd. visio
. Vst = application/x-vst
. Vsw = application/vnd. visio
. Vsx = application/vnd. visio
. Vtx = application/vnd. visio
. Vxml = text/xml
. Wav = audio/wav
. Wax = audio/x-ms-wax
. Wb1 = application/x-wb1
. Wb2 = application/x-wb2
. Wb3 = application/x-wb3
. Wbmp = image/vnd. wap. wbmp
. Wiz = application/msword
. Wk3 = application/x-wk3
. Wk4 = application/x-wk4
. Wkq = application/x-wkq
. Wks = application/x-wks
. Wm = video/x-ms-wm
. Wma = audio/x-ms-wma
. Wmd = application/x-ms-wmd
. Wmf = application/x-wmf
. Wml = text/vnd. wap. wml
. Wmv = video/x-ms-wmv
. Wmx = video/x-ms-wmx
. Wmz = application/x-ms-wmz
. Wp6 = application/x-wp6
. Wpd = application/x-wpd
. Wpg = application/x-wpg
. Wpl = application/vnd. ms-wpl
. Wq1 = application/x-wq1
. Wr1 = application/x-wr1
. Wri = application/x-wri
. Wrk = application/x-wrk
. Ws = application/x-ws
. Ws2 = application/x-ws
. Wsc = text/scriptlet
. Wsdl = text/xml
. Wvx = video/x-ms-wvx
. Xdp = application/vnd. adobe. xdp
. Xdr = text/xml
. Xfd = application/vnd. adobe. xfd
. Xfdf = application/vnd. adobe. xfdf
. Xhtml = text/html
. Xls = application/vnd. ms-excel
. Xls = application/x-xls
. Xlw = application/x-xlw
. Xml = text/xml
. Xpl = audio/scpls
. Xq = text/xml
. Xql = text/xml
. Xquery = text/xml
. Xsd = text/xml
. Xsl = text/xml
. Xslt = text/xml
. Xwd = application/x-xwd
. X_ B = application/x-x_ B
. X_t = application/x-x_t

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.