JSP Directives
JSP Directives
JSP directives provide directions and instructions to the container, telling it how to handle certain
aspects of JSP processing.
A JSP directive affects the overall structure of the servlet class. It usually has the following form:
Directives can have a number of attributes which you can list down as key-value pairs and
separated by commas.
The blanks between the @ symbol and the directive name, and between the last attribute and the
closing %>, are optional.
Directive Description
<%@ page ... %> Defines page-dependent attributes, such as scripting language,
error page, and buffering requirements.
<%@ include ... %> Includes a file during the translation phase.
<%@ taglib ... %> Declares a tag library, containing custom actions, used in the page
Attributes:
Following is the list of attributes associated with page directive:
Attribute Purpose
errorPage Defines the URL of another JSP that reports on Java unchecked
runtime exceptions.
isErrorPage Indicates if this JSP page is a URL specified by another JSP page's
errorPage attribute.
extends Specifies a superclass that the generated servlet must extend
import Specifies a list of packages or classes for use in the JSP as the Java
import statement does for Java classes.
session Specifies whether or not the JSP page participates in HTTP sessions
isELIgnored Specifies whether or not EL expression within the JSP page will be
ignored.
Check more detail related to all the above attributes at Page Directive.
The filename in the include directive is actually a relative URL. If you just specify a filename with
no associated path, the JSP compiler assumes that the file is in the same directory as your JSP.
The taglib directive declares that your JSP page uses a set of custom tags, identifies the location
of the library, and provides a means for identifying the custom tags in your JSP page.
Where the uri attribute value resolves to a location the container understands and the prefix
attribute informs a container what bits of markup are custom actions.