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..
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"
Joined: May 18, 2006
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.
Joined: Mar 18, 2004
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
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.
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.