Share on Google+Share on Google+

Page Directive attribute - contentType

Advertisement
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:

Advertisements

Posted on: November 27, 2012 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.