Directives

Directives are messages to the JSP engine that provide global information for the page or include a file of text or code. Directives begin with the character sequence <%@ followed by the name of the directive and one or more attribute definitions. They end with the character sequence %>.

There are three directives: page, include, and taglib.

Page directive

The page directive defines attributes that apply to an entire JSP, including language, the class being extended, packages imported for the entire page, the size of the buffer, and the name of an error page. For example:

<%@ page language="java" import="mypkg.*"
		session="true" errorPage="ErrorPage.jsp" %>

For more information about error pages, see “Error handling”.

Include directive

The include directive includes a static file, parsing the file’s JSP elements:

<%@ include file="header.htm" %>

NoteInclude directive and include standard tag Note that the include directive parses the file’s contents, while the include tag does not.

Taglib directive

The taglib directive defines the name of a tag library and its prefix for any custom tags used in a JSP:

<%@ taglib uri="http://www.mycorp/printtags"
		prefix="print" %>

If the tag library includes an element called doPrintPreview, this is the syntax for using that element later in the page:

<print:doPrintPreview>
...
</print>

For more information, see “Customized tag libraries”.