Appendix A. JSP Elements Syntax Reference

JSP defines three types of elements: directives, scripting elements, and action elements. In addition, you can define your own custom actions. This appendix contains descriptions of all JSP elements as well as the general syntax rules for custom actions.

Directive Elements

Directive elements are used to specify information about the page itself, especially information that doesn’t differ between requests for the page. The general directive syntax is:

<%@directiveName attr1="value1" attr2="value2" %>

The attribute values can be enclosed with single quotes instead of double quotes. The directive name and all attribute names are case-sensitive.

include Directive

The include directive includes a static file, merging its content with the including page before the combined result is converted to a JSP page implementation class. The include directive supports the attribute described in Table 1.1.

Table A-1. include Directive Attribute

Attribute Name

Default

Description

file

No default

A page-relative or context-relative URI path for the file to include

A page can contain multiple include directives. The including page and all included pages together form what is called a JSP translation unit.

Example:

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

page Directive

The page directive defines page-dependent attributes, such as scripting language, error page, and buffering requirements. It supports the attributes described in Table 1.2.

Table A-2. page Directive ...

Get Java Server Pages now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.