• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

tld for tag?

 
yeshwanth reddy
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

It is mentioned in hsfj that if a tag is placed in jar's META-INF , then a tld file is required. What information does this tld hold and why is it required?

Regards,
Yashwanth
 
Charles Lyons
Author
Ranch Hand
Posts: 836
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't quite understand what you mean: you say "if a tag is placed in a JAR's META-INF" - but a tag is never placed there - in fact there are no such thing as "tags" per-se: you've either got tag handlers (which are Java classes) or tag files (which are JSP-based).

Tag handlers, like all other classes, should be placed in the appropriate directory in the JAR, based on the package name of the handler class. Tag files should go in /META-INF/tags/ or subdirectories.

Back to the TLD: a TLD is a "Tag Library Descriptor" - an XML document which describes what tags are found in the library, what handler classes or tag files implement them, the structure of each tag (what attributes and variables it exposes, and what body content it should have) and provides the tag library author with possibility for a description/example of each tag's use. A TLD for a tag library is loosely similar to a deployment descriptor for a Web application. TLDs go in /META-INF/, or as of JSP 1.2, any subdirectory (in pre-JSP 1.2, the only TLD permitted was /META-INF/taglib.tld).

If that doesn't resolve it, post again...
[ March 16, 2006: Message edited by: Charles Lyons ]
 
Chandra Sagi
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is mentioned in hsfj that if a tag is placed in jar's META-INF , then a tld file is required.[/QB]


Thats correct. The container searches for a tag file automatically under WEB-INF/tags, sub-directory of WEB-INF/tags. It could also be placed under META-INF/tags directory inside a JAR file that's inside WEB-INF/lib, or a sub-directory of META-INF/tags directory inside a JAR file that's inside WEB-INF/lib. If the tag files are placed inside a JAR then it must have a TLD which shows the location.

The TLD for the Tag file inside a JAR will look like this

<taglib...>
<tlib-version> 1.0 </tlib-version>
<uri>myTagLibrary</uri>
<tag-file>
<name>Header</name>
<path>/META-INF/tags/Header.tag</path>
</tag-file>
</taglib>

Hope this helps


Thanks
Chandu
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic