Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Taglib and Tagdir question?

 
Ernesto Leyva
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 284
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 :
/WEB-INF/foo/bar/atag.tag
 
Ernesto Leyva
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok thanks for the answer
 
Alex Matute
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...

--alex


-------------------------
SCJD
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic