JSP Tag Library , TLD Example

A tag library allows a developer to group together tags with related functionality. A tag library uses a tag library descriptor (tld) file that describes the tag extensions and relates them to their Java classes.

JSP's offer a unique feature of "Tag Libraries". Simply put, these are custom defined JSP tags. They are basically meant for componentizing presentation level logic. They are very similar to beans except the fact that Beans are used to separate Business logic.

Every tag is mapped to a particular class file which is executed whenever the tag is encountered in an JSP file. The general syntax :

Follows the general syntax for including a particular tag library from a jsp.

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


Follows a example tld,


PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">




1.0
1.1
Nefunda

Nefunda Contact feature Tag





contactEmailForm
com.nefunda.tag.ContactFormsTag
JSP

This tag emails the attributes of the HttpServletRequest
to the email id set up for a particular form, subject or
optionally a hotel






Here the implementation class is com.nefunda.tag.ContactFormsTag.

Comments

  1. This is a great article keep posting.....

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete

Post a Comment

Popular posts from this blog

Difference between volatile and synchronized

Converting Java Map to String

Masking Credit Card number in Java