File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes tag files JAR, there must be a tld 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 "tag files JAR, there must be a tld" Watch "tag files JAR, there must be a tld" New topic
Author

tag files JAR, there must be a tld

Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
I have two queries:

1- What if I have a tag file bundled in the JAR, and that tag file is not
defined in the TLD, would this cause translation error by the container?

2- For each tag files, there would be separate OR one tag library.


Thanks,


cmbhatt
khushhal yadav
Ranch Hand

Joined: Jun 20, 2007
Posts: 242

Hi Chandra,

If your tagf iles are in a JAR under lib directory.
Your container woon't be able to locate them.
And hence, yes, you will get the translation error.

For that, you have to define a TLD.
And the location of that TLD should be META-INF directory.

You can configure more than one tag files in a single TLD.
That depends on your preference.

Regards,
Khushhal


rgrds,
Khushhal
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
Hi khushhal,

Suppose I have couple of tag files named test1.tag, test2.tag and test3.tag
located in /WEB-INF/tags/mytags, would container consider them all part
of the same tag library.

Question may sound awkward!


Thanks,
khushhal yadav
Ranch Hand

Joined: Jun 20, 2007
Posts: 242

Hi Chandra

For that, you can do something like this



You can even combine tag files, tag or function declaration.
No problem.. All we concern about is a uri for all the stuff declared in that tag library.

Regards,
Khushhal
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
Right!

Seeing your code schema, I recall one more thing that container automatically
generates tab library descriptor. Is this same generated by the container as
you posted just above?


Thank you very much for your quick replies!
khushhal yadav
Ranch Hand

Joined: Jun 20, 2007
Posts: 242

container automatically generates tab library descriptor.


Yes,it's true.
But not if your tag files are within JAR.
You will have to explicitly specify it in that case.

Regards,
Khushhal
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
Absolutely!

Million $ factor:

"If the tag file is deployed in a JAR, there must be a TLD for the tag file."

Thanks for your help!
Deepa Jaine
Greenhorn

Joined: Jan 27, 2006
Posts: 4
Hi Chandra,

Suppose I have couple of tag files named test1.tag, test2.tag and test3.tag
located in /WEB-INF/tags/mytags, would container consider them all part
of the same tag library.

Question may sound awkward


NO, the question is not awkward.
From where did you get this question? I attempted my SCWCD exam today and a similar question was there in the exam I will write a different post regarding my exam.

[Christophe: do not post real questions]

After reading this post, I know that my answers were wrong. What does it mean by tag library, is it TLD? I thought it's a different thing. I just read that if we don't specify the tag file which is in a JAR, in a TLD, container will just ignore it. In that case answer 3 is wrong, right?

[ August 15, 2007: Message edited by: Deepa Mj ]

[ August 15, 2007: Message edited by: Christophe Verre ]
[ August 17, 2007: Message edited by: Deepa Mj ]
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
Deepa:

--> I just read that if we don't specify the tag file which is in a JAR, in a TLD, container will just ignore it.


I don't thing this is correct.
Refer to page 499 Head First.

"IF the tag file is deployed in a JAR, there MUST be a TLD for the tag file."

I still have doubt that it is must a tag file to reside in either of the
four location:
[1-2]: /WEB-INF/tags or its subdirectory
[3-4]: /META-INF/tags or its subdirectory that resides in the /WEB-INF/lib

My confusion is, if my tag files are not deployed in the JAR file,
is it correct that for multiple tag files, container will create a single
tag library descriptor.


Deepa: The question arose from the factor that why is it required to have
TLD if tag files are deployed in the JAR.

Thanks,
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
I just read that if we don't specify the tag file which is in a JAR, in a TLD, container will just ignore it.



I agree with you, if you say you don't that tag file as tag. That means
that file can't be used as tag file because container can't locate it
until you have a TLD for that.

Thanks,
khushhal yadav
Ranch Hand

Joined: Jun 20, 2007
Posts: 242

Hi Chandra

Still Confused

My confusion is, if my tag files are not deployed in the JAR file,
is it correct that for multiple tag files, container will create a single
tag library descriptor


The container builds an implicit tag library and TLD for tags directory and each subdirectory beneath it.

The good new is that you don't have to create TLDs for tag files.
The bad news is that for that your tag files must be in /WEB-INF/tags or it's subdirectory.
Otherwise you have to externally create a TLD for each directory. There will be one TLD per directory not per tag file as shown in one of the snippet posted in my earlier post.

Regards,
Khushhal
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
Very well!



Thanks khushhal,
 
Don't get me started about those stupid light bulbs.
 
subject: tag files JAR, there must be a tld
 
Similar Threads
TLDs and Tag Files
Can someone explain me the meaning of this question?
Unable to use tag file deployed in jar file
some questions
tagdir attribute