Since tag libraries encapsulate common functionality and it is inevitable that you will find specific functionality that is common among your application s JSPs, they quickly become a very useful and productive tool. Creating custom tag libraries helps JSP developers keep a consistent look and feel across the various pages as well as reduce duplicated functionality. The following example is a simple custom tag that can access a list of employees from the database and create a select list. We will need to create a Tag Library Descriptor (TLD) file and the Java code to handle the tag. First, we will define our TLD file. This example uses the file name taglib.tld and is saved in the META-INF directory under the source directory. The source for the following TLD file defines one tag called selectEmployee. The selectEmployee tag has three attributes ( name , selectedId, and size ):
<?xml version =