Name

Attribute Directive

Synopsis

This directive can only be used in tag files. It declares the attributes the tag file supports.

Syntax

<%@ attribute name="attrName" 
  [description="description"] [required="true|false"]
  [fragment="true|false" | [type="attrDataType"] [rtexprvalue="true|false"]]
%>

Attributes

Attribute name

Default

Description

description

No default

A description of the attribute that can be presented to a page author by an authoring tool.

fragment
false

Set to true if the attribute represents a fragment, set by a <jsp:attribute> element. If false, the attribute is converted to the type specified by the type attribute.

name

No default

The attribute name.

required
false

Set to true if the page author must provide an attribute value.

rtexprvalue
true

Set to false if the attribute value must be provided as a static text value. If true, the attribute can be set by an EL or Java expression or a <jsp:attribute> element, evaluated at runtime.

type
String

The attribute data type. Primitive types are not supported, only Java classes and interfaces.

When the fragment attribute is used, the rtexprvalue and type attributes must not be used. For a fragment, a runtime expression value is always accepted and the type is fixed to javax.servlet.jsp.tagext.JspFragment.

Example

<%@ attribute name="date" type="java.util.Date" %>
<%@ attribute name="pattern" fragment="true" %>

Get JavaServer Pages, 3rd Edition 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.