• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EPractice Lab reivew exam 1 ,about the directory of tag files

 
Himai Minh
Ranch Hand
Posts: 1359
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Which of the following values of tagdir attribute of the taglib directive is invalid?
a. /WEB-INF/tags.
b. /META-INF/tags
c. /WEB-INF/tags/mytagidr
d./WEB-INF/custom-tags
Given answer is B.
The tagdir attribute is used to specify the directory where the tag extensions are installed.The valid values are
/WEB-INF/tags or any of its subdirectory.If any other value is given, a compilation error will occur.


I think d is invalid too. Tag files must be in /WEB-INF/tags or subdirectory in the web application. If it is in a jar file, it must be in /META-INF/tags.
If the tag file is within a jar file, it can only be refered by uri attribute, not tagdir attribute.

Reference:
http://www.coderanch.com/t/601954/java-Web-Component-OCEJWCD/certification/understand-tagdir-attribute-taglib-directive

1) Tag File is located in /WEB-INF/tags/ or one of its subdirectories
2) Tag File is located in /WEB-INF/lib/ in a Jar file and then inside the Jar file in a directory /META-INF/tags or one of its subdirectories

An URI can only be used if your are trying to access a Tag-file that is located in the Jar-file. The TLD will then tell the container where to find the Tag-file.
If you are using a Tag file located in /WEB-INF/tags (and the tagdir attribute in the JSP) the container will generate a TLD that will point to the Tag file, making the two possibilities almost equal.


http://www.coderanch.com/t/178207/java-Web-Component-OCEJWCD/certification/taglib-directive-tagdir-uri

The tag files *.tag must reside in jar-file/META-INF/tags or subdir of it and
a tld file must exist in jar-file/META-INF or subdir of it with <uri>someURI</uri> tag in it .


Based on the above two posts, b is not valid. We cannot use tagdir="/META-INF/tags" to refer to a tag file in a jar.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2531
112
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with you. Nice explanation!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic