|Oracle JavaServer Pages Developer's Guide and Reference
Part Number A83726-01
You can use the
contentType parameter to set the MIME type and to optionally set the character encoding for a JSP page. The MIME type applies to the HTTP response at runtime. The character encoding, if set, applies to both the page text during translation and the HTTP response at runtime.
Use the following syntax for the
or, to set the MIME type while using the default character set:
TYPE is an IANA (Internet Assigned Numbers Authority) MIME type and
character_set is an IANA character set. (When specifying a character set, the space after the semi-colon is optional.)
The default MIME type is
text/html. The IANA maintains a registry of MIME types at the following site:
The default character encoding is
ISO-8859-1 (also known as Latin-1). The IANA maintains a registry of character encodings at the following site (use the indicated "preferred MIME name" if one is listed):
(There is no JSP requirement to use an IANA character set as long as you use a character set that Java and the Web browser support, but the IANA site lists the most common character sets. Using the preferred MIME names they document is recommended.)
The parameters of a
page directive are static. If a page discovers during execution that a different setting is necessary for the response, it can do one of the following:
page directive that sets
contentType should appear as early as possible in the JSP page.
ISO-8859-1 must set the appropriate character set in a
page directive. It cannot be set dynamically because the page has to be aware of the setting during translation. Dynamic settings are for runtime only.