Using TLD files

How to use Tag Library Descriptor file in JSP?


In a JSP page the classes to be used are included from a "tld" file using the tags. Tags with the "prefix" of a paticular tld file, along with the class name are used in a JSP page.

Example :

<%@ taglib uri="WEB-INF/tlds/mytag.tld" prefix="sample" %>
<title>Your Standard Hello World Demo</title>
<body bgcolor="#ffffff">
<sample:hello name="hello1"/>
<sample:enc name="encrypt1"></sample:enc>
Result :

Welcome hello1
Your Encrypted Password is=encrypt1c3a6478ff5ff7a243a53251ea5faf5

In the above Tag Library Descriptor example, the file "uri="WEB-INF/tlds/mytag.tld"" point to the tag library "mytag.tld". The prefix "sample" is used to refer this tag library. To display a "Hello1" message the class "" is included in the JSP using this code "<sample:hello name="hello1"/>". The encrypted value of the password is displayed using the "".

Ask Questions

Ask Question