In this section we are going to discuss the page directives which is one part of Directives.
In this section we are going to discuss the page directives which is one part of Directives.In this section we are going to discuss the page directives which is one part of Directives.
page Directives :
Functionality of page directive is to define the page dependent attributes to the JSP container. For example scripting language, error page, and buffering requirements. In general we write page directives at the top of the JSP page. page is used to provide the information about it.
Syntax -
<%@ page attributes="value" %>
Attributes : attributes associated with page directive:
buffer Attribute : This attribute is used for specifying the buffer size for the output stream.
Example :
<%@ page buffer="8kb" %>
autoFlush Attribute : This attribute is used to control the nature of the servlet output buffer.
Example :
<%@ page autoFlush="true" %>
contentType Attribute : The contentType attribute defines the MIME type for the response an defines the character encoding scheme.
Example :
<%@ page contentType="text/html" %>
errorPage Attribute: Functionality of errorPage attribute is used to define the error page. If there is exception then the JSP page is redirected to the error page.
Example :
<%@ page errorPage="ErrorPage.jsp" %>
isErrorPage Attribute: This attribute represents weather the page is intended to be an error page of some other JSP page.
Example :
<%@ page isErrorPage="true" %>
extends Attribute : This attribute specifies the super class of the JSP page's implementation servlet.
Example :
<%@ page extends="superClass" %>
import Attribute : This page attribute imports a list of packages and classes separating with comma (,).
Example :
<%@ page import="java.util.*,java.sql.*" %>
info Attribute : This attribute simply sets the information of the JSP page which is retrieved later by using Servlet.getServletInfo() method. The value of the attribute will be a text string.
Example :
<%@ page info="Info about this page" %>
isThreadSafe Attribute : This attribute defines the behavior of threads. It specifies that the thread is safe or not.
Example :
<%@ page isThreadSafe="true" %>
language Attribute : This attribute of page directive specifies the other scripting languages to be used by the JSP page.
Example:
<%@page language="java" %>
session Attribute : session attribute of page Directive indicates that the page is participating in session or not.
Example :
<%@ page session="true" %>
isELIgnored Attribute : This attribute is boolean type, specified value true if any of the EL expressions will be ignored in the JSP page.
Example :
<%@ page isELIgnored="false" %>
pageEncoding Attribute : This attribute of page directives is character encoding where the file is encoded.
Example:
<%@page pageEncoding="ISO-8859-1" %>
Another attribute -
isScriptingEnabled Attribute: This attribute is used to check whether scripting elements are allowed for use or not.
Example :
<%@ page isScriptingEnabled="false" %>