• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Possible error in question?

 
JohnWilliam Fitz
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.

In Charles Lyon's book on p497, question #7 says the following...

Q: "A tag file is deployed directly to the Web application into the file /WEB-INF/tags/library/mytag.tag. Which of the following statements are true?"

...I won't give all the choices here. I will just give the one that is marked as correct that I think could be an error...

A: "A JSP page using this tag library with prefix 'my' should declare the following: <%@ taglib tagdir="/WEB-INF/tags/library/mytag.tag" prefix="my" %>"

Now, I think that the tagdir attribute can point at a "tld" file. But I've never seen it point at a tag file directly, and cannot find any mention of that in any of my books.

Can anyone clarify? Am I missing something?

Thanks!
 
Omar Al Kababji
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suppose that you know what is a tag file used for, so the question is how could you use a tag file in your JSP file ?

the answer is you use the prefix you specify and the name of that tag file

<prefix:tagFileNamePluseTagFileName/>

however if you place the tag file in some directoty you cant do somthing like this

<prefix:FullPathToTagFile>

so you have to specify the tagdir attribute of the taglib directive to point to the location of your tagfile ;)


(peace)
 
JohnWilliam Fitz
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply.

However in the answer that is given as correct there is a tag *FILE* name in the "tagdir" attribute. Everything I have read so far says you should have a DIRECTORY name in the tagdir attribute. I have never read anywhere that this it is legal to list a tag file name there, and I cannot get it to work on Tomcat 5.

With all due respect and gratitude for you assistance, I still think the answer is wrong.

Regards,
Joh
 
Omar Al Kababji
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes but nothing prevents you from naming a directory mytag.tag got my point ;)

you can have a directory named WEB-INF/tags/mytag.tag/ and inside this directory you have mytag.tag so the path to the file is:

WEB-INF/tags/mytag.tag/mytag.tag
1 2

where (1) is a directory even if it look like a tag file name, and 2 is a tag file.

so to specify its taglib directive you have to write:

<@ taglib prefix="myTags" tagdir="WEB-INF/tags/mytag.tag"



its very strange but when you don't find a correct and logical answer you have to start looking at the most correct ;). however yes you are right that you have to specify only the path to the folder containing the tag file without mentioning the name of the tag file.

(peace)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic