Meaningless Drivel is fun!*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Regarding TLD Location 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 "Regarding TLD Location" Watch "Regarding TLD Location" New topic
Author

Regarding TLD Location

vinod balaji
Ranch Hand

Joined: May 18, 2006
Posts: 84
HFSJ: PgNo:611,
QNO 2: Where do you store TLDs in a Web Application.
A. Only in /web-inf/lib
B. Only in /Web-inf/classes
C. In the /Meta-Inf directory of a Jar File Inside /web-inf/lib.
D....
E. in/Web-Inf or a sub-directory thereof.

HFSJ answer: C,E.

I have doubt in Option E.
In my understanding, TLD's are used to find the tag class files if the tag files is used outside the web-inf/tags directory, so it is understood that there is no need to store TLD in web-inf directory..
Please Correct me if i am wrong..

Thanks.
Ali Gohar
Ranch Hand

Joined: Mar 18, 2004
Posts: 572
Option C and E are correct. we place the .tag files in WEB-INF/tags or sub directory. Whereas if we are creating custom tags using classes then we have to specify a TLD, in case if these tags are packaged as jar files, the TLD files are placed in META-INF directory of that jar file.

We can also place TLD files in WEB-INF or any sub directory of WEB-INF and then in JSP we just specify the path of TLD file as "WEB-INF/myTld.tld"
vinod balaji
Ranch Hand

Joined: May 18, 2006
Posts: 84
Thanks, still i am not clear. What is the need for placing TLD's in Web-inf folders, as the container can find the classes without the help of TLD's.
Ali Gohar
Ranch Hand

Joined: Mar 18, 2004
Posts: 572
We place the tag class files in WEB-INF/classes/... folder and as you know we also need a ".tld" file to explain our custom tags. So we have to specify that TLD file path in our JSP file before using our custom tag.

We can place the TLD file inside WEB-INF folder or its sub folder and can specify in JSP file using

<%@taglib uri="/WEB-INF/mytld.tld" prefix="mytag">

then we can use this mytag inside the JSP.
vinod balaji
Ranch Hand

Joined: May 18, 2006
Posts: 84
Thanks Ali, But in Pgno 499(HFSJ) they have mentioned that the " if the tag file is deplyed in a JAR , there must be a TDL for that tag file".i understand from this that we dont need to use tld if we have tag files inside webinf folder.. Please clear my doubt.

Thanks once again.
vinod balaji
Ranch Hand

Joined: May 18, 2006
Posts: 84
Ok i got the answer, Thanks for your reply.
Gowher Naik
Ranch Hand

Joined: Feb 07, 2005
Posts: 643
TLD's are not used to find class they are used to map class with required tags used in jsp file.
For eaxmple i have a jsp file using tag as shown
<%@ taglib prefix="mine" uri="myTag" %>
now tld is used to map above uri with tag class.
lly tag attribute is defined in tld.
Everytning you want to know a abt tag will be present in tld file.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regarding TLD Location
 
Similar Threads
HFJS problem in running JSTL
question9 from HFSJ mock exam
Tag Libraries
BETA - Question about directory structure and taglib
question about tld