Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regarding TLD Location

 
vinod balaji
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 572
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 572
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok i got the answer, Thanks for your reply.
 
Gowher Naik
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic