Home arrow Java arrow Page 3 - JSP Custom Tags: Bringing Components to the Web
JAVA

JSP Custom Tags: Bringing Components to the Web


This article explains what a JSP custom tag is, how to create one, and why you should use them in your web development projects.

Author Info:
By: A.P.Rajshekhar
Rating: 4 stars4 stars4 stars4 stars4 stars / 13
June 13, 2006
TABLE OF CONTENTS:
  1. · JSP Custom Tags: Bringing Components to the Web
  2. · Creating a Custom Tag, Step By Step
  3. · Creating a Custom Tag continued
  4. · Custom Tags in the Real World

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
JSP Custom Tags: Bringing Components to the Web - Creating a Custom Tag continued
(Page 3 of 4 )

Creating the TLD File

As mentioned before, a TLD file is an XML document that describes the library. The TLD  contains the information about the library as a whole, as well as about individual tags. The information about the complete library is provided with the XML tags in the following table.

XML Tag

Definition

<taglib>

 The tag library itself. The following tags are the child nodes of this tag.

<tlibversion>

The tag library's version.

<jspversion>

The JSP  version that is required to make the tag work.

<shortname>

A simple default name with a mnemonic value. For example, <shortname>  may be used as the preferred prefix value in taglib directives and/or to create prefixes for IDs.

<uri>

An optional URI that uniquely identifies the tag library.

<info>

Descriptive information about the tag library.

           

 The tag specific info is described using the following XML tags: 

  • <tag>: The data about the tag itself is described by the siblings of this tag, which are detailed below. 
  • <name>: The name by which the tag would be accessed is given by this XML element. 
  • <tagclass>: The name of the class that handles the tag, a.k.a  the tag handler's name. the value of this element must be fully qualified Java name.
  • <bodycontent>: The value of this tag determines whether the content of the tag has to be considered or not. There can be three values: empty to indicate that the tag has no body, and that an error will be produced if it has one; tagdependent, to indicate that the body is only processed by tag; and JSP, which states that the JSP container should evaluate any body of the tag.
  • <attribute>: The info about the tag's attribute. The following child nodes provides various information:
    • <name>: Name of the attribute.
    • <required>: Declares whether the attribute is mandatory or not.
    • <rtexpvalue>: Lets the <attribute> tag use a runtime expression value if the value of this element is set to "true" or "yes."

That covers the contents of the TLD file. In the next section I will be creating a tag. In it the above tags will be used to create the mapping. So here comes the (nearly) real world example.


blog comments powered by Disqus
JAVA ARTICLES

- Deploying Multiple Java Applets as One
- Deploying Java Applets
- Understanding Deployment Frameworks
- Database Programming in Java Using JDBC
- Extension Interfaces and SAX
- Entities, Handlers and SAX
- Advanced SAX
- Conversions and Java Print Streams
- Formatters and Java Print Streams
- Java Print Streams
- Wildcards, Arrays, and Generics in Java
- Wildcards and Generic Methods in Java
- Finishing the Project: Java Web Development ...
- Generics and Limitations in Java
- Getting Started with Java Web Development in...

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 3 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials