Contents | Prev | Next


Taglib Directive

Defines a tag library and prefix for the custom tags used in the JSP page.

Syntax

<%@ taglib uri="URIToTagLibrary"  prefix="tagPrefix" %>

Examples

<%@ taglib uri="http://www.jspcentral.com/tags" prefix="public" %>

<public:loop>
.
.
</public:loop>

Description

The <%@ taglib %> directive declares that the JSP file uses custom tags, names the tag library that defines them, and specifies their tag prefix.

Here, the term custom tag refers to both tags and elements. Because JSP files can be converted to XML, it is important to understand the relationship of tags and elements. A tag is simply a short piece of markup that is part of a JSP element. A JSP element is a unit of JSP syntax that has an XML equivalent with a start tag and an end tag. An element can also contain other text, tags, or elements. For example, a jsp:plugin element always has a <jsp:plugin> start tag and a </jsp:plugin> end tag and may have a <jsp:params> element and a <jsp:fallback> element.

You must use a <%@ taglib %> directive before you use the custom tag in a JSP file. You can use more than one <%@ taglib %> directive in a JSP file, but the prefix defined in each must be unique.

The technique for creating custom tags is described in the JavaServer Pages Specification for version 1.1.

Attributes



Contents | Prev | Next

Copyright © 2000, Sun Microsystems, Inc. All rights reserved.