JSPs : taglib Directives


 

JSPs : taglib Directives

In this section we are going to discuss the taglib directives which is one part of Directives.

In this section we are going to discuss the taglib directives which is one part of Directives.

JSPs : taglib Directives

In this section we are going to discuss the taglib directives which is one part of Directives.

taglib Directives :

Taglib directive is one of directive of JSP pages. It defines the tag library which is collection of tags. There is standard as well as custom tag libraries. Standard tag libraries are pre-defined libraries and the custom tag libraries are the user defined libraries.

It has two important attribute which is needed at the time of writing taglib description.

  • uri : Locates the TLD file of a custom tag.
  • prefix : Defines a prefix string to be used for distinguishing a custom tag instance.

Syntax:

<%@ taglib uri="uri" prefix="prefixOfTag" >

Example : In this example we are using taglib directive and print the variable content.

<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
<title>taglib Example.</title>
</head>
<body>
<font color="blue" size="5"> 
<c:set var="name" value="This is taglib Example."></c:set>
<c:out value="${name}"></c:out>
</font>
</body>
</html>

Output :

Ads