In this tutorial you will learn about the 'taglib' directive in JSP.
JSP taglib Directive
In this tutorial you will learn about the 'taglib' directive in JSP.
taglib directive element when used in jsp file it declares that the file uses custom tags or you can say that 'taglib' directive must be used before when there is a custom tag is used in jsp file. It defines the name of the tag library and specifies the prefix for their tag. In a jsp file 'taglib' directive can be used more than one time but the prefix specifies for each of their tag must be unique.
Syntax :
<%@ taglib uri="URIToTagLibrary" prefix="tagPrefix" %>
Here value of attribute 'uri' is a location, where a tag library description will be found and the value of attribute 'prefix' specifies the custom action's bits of markup. For example :
<%@ taglib uri="WEB-INF/dev.tld" prefix="dev" %> <dev:hello> </dev:hello>
Note : As a prefix values "jsp, jspx, javax, java, servlet, sun, sunw" can not be used by you because these are reserved by Sun Microsystems.
Example :
The example given below is a dummy example.
<%@ taglib uri="WEB-INF/dev.tld" prefix="dev"%> <html> <head> <title>A sample custom tag</title> </head> <body> <dev:myTag>Hello</dev:myTag> </body> </html>
[ 0 ] Comments