It's not a secret anymore!*
The moose likes JSP and the fly likes Is tld file necessary? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSP
Bookmark "Is tld file necessary?" Watch "Is tld file necessary?" New topic
Author

Is tld file necessary?

mara thamizhan
Ranch Hand

Joined: Jul 05, 2006
Posts: 74
Dear dudes,
I was working with JSTL , in which i'm using pre-defined tag libraries which contains many functionalities which is defined in TLD files. For example:

<%@ taglib uri="WEB-INF/tld/struts-html" prefix="html" %>
Here this means i can use the html tags functionality which is defined in the uri i.e. tld files which defines the class and functionality.

here if i use some X() functionality in html tags, the container goes through the tld files and finds the corresponding method or function.

Why this should be like this?

<%@ taglib uri="WEB-INF\lib\struts.jar" prefix="html" %>

Why can't i directly refer the location of resource ( here the jar file) to the container so that these intermediate tld file mapping can be skipped.

Why is the tld file significant?

Any valid reply would be appreciated.

regards.
Pedro Erencia
Ranch Hand

Joined: Apr 03, 2008
Posts: 70
Are you asking about the need of the tld itself or just the uri ?
mara thamizhan
Ranch Hand

Joined: Jul 05, 2006
Posts: 74
I'm asking about the need of the tld itself?

About the uri, whether it should match the tag-lib uri we specify in our web.xml or it should match the uri we specify inside the tld file.
How the container tracks the corresponding class file & if that can be done that path we can directly specify in our webpage itself instead of going through tld files.

For example if my struts.jar is in WEB-INF/lib/struts.jar
<%@ taglib uri="WEB-INF/lib/struts.jar" prefix="html" %>

Why this is not possible?
Pedro Erencia
Ranch Hand

Joined: Apr 03, 2008
Posts: 70
I'm asking about the need of the tld itself?


Maybe a dot ? It seems to me by what are you saying later.




How the container tracks the corresponding class file & if that can be done that path we can directly specify in our webpage itself instead of going through tld files.


A tld contains metadata about an entire tag library. Each tag inside this tag library can be implemented in a differente tag class. Moreover, how do you express if an attribute is required or if it can be an rtexpr in the class file ?

For example if my struts.jar is in WEB-INF/lib/struts.jar
<%@ taglib uri="WEB-INF/lib/struts.jar" prefix="html" %>

Why this is not possible?


This is possible whenever you include a tld called taglib.tld inside the META-INF directory inside the jar.
 
GeeCON Prague 2014
 
subject: Is tld file necessary?