JSP Taglib Directive

Taglib directive is used to define tag libraries in JSP page. It enables user to use custom tags within JSP file. A JSP page can contains more than one taglib directives.

Syntax of Taglib Directive

<@ taglib uri="uri" prefix="value">

Here, uri represents the path of tag library description and prefix represent the name of custom tag.

Example of Taglib directive

Here is a simple example of taglib directive. To run this code you need to add jstl jar file within lib directory of your project. It is better to run this code after learning JSTL.

index.jsp

</html>
<head>
<title>Tutorial and Example</title>
</head>
<body>
<h2 align="center">
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:out value="Welcome to JSP Taglib Directive"/>
</h2>
</body>
</html>

We will learn more about taglib directive in JSP custom tag.