Page Directive attribute - contentType


 

Page Directive attribute - contentType

This section contains description of contentType attribute of page Directive.

This section contains description of contentType attribute of page Directive.

Page Directive attribute - contentType

This section contains description of contentType attribute of page Directive.

contentType Attribute :

The contentType attribute defines the MIME type for the response an defines the character encoding scheme. By using this attribute you can set the 'type of content' for the response. You can also use any of MIME type or character set which is valid for jsp page.
By default MIME type value for jsp page is text/html in standard syntax and text/xml for jsp documents in XML syntax.

Syntax -

For XML documents for jsp, we will use following page directives -

<%@ page contentType="text/xml" %>

For HTML page, we will use following page directives -

<%@ page contentType="text/html" %>

For Microsoft Word document, we will use following page directives -

<%@ page contentType="application/msword" %>

For character encoding for the response, we will use following page directives -

<%@ page contentType="text/html:charset=ISO-8859-1" %>

Example :

<%@page contentType="text/html"%>

<html>
<body>
<table border="1" cellspacing="0" cellpadding="0" bgcolor="aqua">

<tr>
<td><strong>Welcome! This is your html page.</strong></td>
</tr>

</table>
</body>
</html>

Output:

Ads