It's not a secret anymore!
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Taglib and Tagdir question? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Taglib and Tagdir question?" Watch "Taglib and Tagdir question?" New topic

Taglib and Tagdir question?

Ernesto Leyva
Ranch Hand

Joined: Feb 23, 2006
Posts: 62
I got a question regarding tag files:

According to the HFJS a tag file can be only in the following places:

1) WEB-INF/tags
2) WEB-INF/tags/<subdirectory>
jar file:
3) META-INF/tags
4) META-INF/tags/<subdirectory>

Additionally the extension of the tag file should be: tag
and the name of the tag file and custom tag must match.

Then what is the purpose of using the "tagdir" in the page directive "taglib" i.e.

<%@ taglib prefix="mytag" tagdir="WEB-INF/tags" %>

The container by default should search and match my tag with the standard places. The only I can think of is performance optimization.
Frederic Esnault
Ranch Hand

Joined: Feb 13, 2006
Posts: 284
tagdir is usedto specify the directory relative to which the container must look for your tagfiles:

You may use
<%@ tagdir="WEB-INF/tags/foo/bar" prefix="myTags" %>

then use a tag like this :
<myTags:atag/> to access a tag file which path is :

SCJP 5 - SCWCD 1.4 - SCBCD 1.3 - Certification study documents/resources:
Ernesto Leyva
Ranch Hand

Joined: Feb 23, 2006
Posts: 62
ok thanks for the answer
Alex Matute

Joined: Jun 28, 2005
Posts: 14
Sorry guys, but I still don't understand. I agree with Ernesto in that I don't see the point of using tagdir, since the TAG files will still be searched by the container in the 4 places that p. 499 indicates; or will it listen to the tagdir attribute and ignore those 4 places if the attribute exists? In that case, tagdir should not be mandatory, is it?

Frederic, according to your example, where does this 4 places take place?

Pleasy clarify...


I agree. Here's the link:
subject: Taglib and Tagdir question?
It's not a secret anymore!