File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Tag Libraries Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Tag Libraries" Watch "Tag Libraries" New topic

Tag Libraries

Abhinav Sharma

Joined: Aug 08, 2001
Posts: 25
Hi friends,
I am in deep trouble. Can anyone tell me What is tag library?
Actually i am using Jrun. And the book i am from where i am reading is based on weblogic server. So the syntax which they use for taglib directive is :-
<%@ taglib uri="META-INF.taglib.tld" prefix="example" %>
Where else uri is the path for the tld file. In JRun there is no file whose extension is tld. Infact there is no file with the extention of tld in my whole hard disk. Does that means that tag library directory is only possible through web logic server and through Jrun. There is no folder which has its name META-INF but there is one folder which has got name web-inf. How do i create or use tag library. Can anyone tell what does this tag library does and how it is important.
I have by mistake posted this same topic in Applets forum where Mr tim said "The taglibrary descriptor is simply an XML file that describes the tag library's properties. The recommended location to store tlds is in WEB-INF, not META-INF, since that's a convenient place for items that the user should not have direct access to but are needed by the web application. The tag classes themselves are in the WEB-INF/class or WEB-INF/lib directories just like all the other classes for the web app." But the book i am reading says that is is in META-INF. And i have searched for the tld files in web-inf file also but there was a file whose name is "web.xml". Is this the same file which we have access for taglibrary. Please give me some diea.
Thanks in advance
Sarath Mohan
Ranch Hand

Joined: Mar 17, 2001
Posts: 213
As Tim said, you should create your own Tab Library Descriptor (tld).
Do you have a JRun server installed in your m/c on in your n/w?
Then you can place any directory related to web-app root
directoy. For simple programs you can put tlds in same directory where you store your jsps.
and cans simply specify uri attribute as attribute="myTag.tld".
If you are new to tag libraries refer a book first.

Sarath Mohan
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17410

It's not really important where you put your taglibrary descriptors as long as they are accessible by the JSP. I don't recommend putting them in the same directory as the web pages, because that directory is often wide open to direct client access . People could do an HTTP GET for and possibly view the TLD file, which means that they can find out things about the inner workings of your website that might help them do something bad.
WEB-INF/web.xml is a file used by the application server to describe the application and really has nothing to do with tags.
META-INF is the place where general information about a Java Archive (JAR) is stored, and is unimportant to a web app. If the application wasn't stored in a JAR, this directory probably won't even exist. That may be another reason why TLDs are recommended to go in WEB-INF, instead.
I haven't worked with JRUN since before JSPs existed - if you have an old copy, maybe the is the reason you don't have any examples is that all that stuff is relatively new.
A TLD isn't mandatory, BTW. They're only needed to support custom tags. Also, it's not uncommon to have multiple taglibraries in a project. Right now, the jakarta Struts system makes use of 4. Each one has its own taglibrary descriptor file (TLD).

An IDE is no substitute for an Intelligent Developer.
Bill Siggelkow
Ranch Hand

Joined: Jun 27, 2001
Posts: 57
The convention I have used is store tld files in WEB-INF\tlds

Bill Siggelkow
Jade Cove Solutions
Abhinav Sharma

Joined: Aug 08, 2001
Posts: 25
Thanks tim and binu for your much requiered help. I am working on your suggestions. And sorry could not come lately.
I agree. Here's the link:
subject: Tag Libraries
It's not a secret anymore!