Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About resolving URIs to TLD file locations

 
Ailsa Cape
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone!

I am a bit confused about resolving URIs in the JSP file to TLD file locations. Say, there is a test.jsp file which is located in the <web application root directory>\jsp\test.jsp. In this file, a taglib directive declared as <%@ taglib prefix="hello" uri="sampleLib.tld" %>. I think when the JSP enginee encounters the directive, it does the following two things,

(1) First, it checks the taglib map. If there is an explicit mapping in web.xml file, which has defined something as,
<taglib-uri>sampleLib.tld</taglib-uri>
<taglib-location>realLib.tld</taglib-location>
then the container will associate this URI to the actual TLD file-realLib.tld which is located in <web application root directory>\WEB-INF\realLib.tld.
In other case, if the <taglib-location>element defines as <taglib-location>/realLib.tld</taglib-location>, then the container will find the real TLD file-realLib.tld in the <web application root directory>realLib.tld.

(2) Second, if there is not any matching in the taglib map, the container will expect to find the real TLD file-sampleLib.tld in the same directory as the current test.jsp file, which directory is <web application root directory>\jsp\sampleLib.tld.

I want to know whether the workflow mentioned above is correct and the TLD file locations which I use bold characters are right in every case.

I also find if a TLD file packaged in a JAR file, a lot of examples use absolute URI to define the TLD file's <uri> element. Do we have to use absolute URI instead of relative URI? I think both URIs can be used in such situation. Is it right?

Thanks in advance!
Regards, Ailsa Cape
[ February 12, 2006: Message edited by: Ailsa Cape ]
 
muthu kumaran
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ailsa ,

The First thing you should note is " The URI need not point to the location where the TLD is stored. It is present only to resolve namespace issues."

Coming to your points on the TLD mapping

Point 1 is perfect( if a taglib element is present in the DD then the container first looks at it to find the TLD file)

Coming to the second point


if there is not any matching in the taglib map, the container will expect to find the real TLD file-sampleLib.tld in the same directory as the current test.jsp file, which directory is <web application root directory>\jsp\sampleLib.tld



This is not correct . The container expects to find the TLD files only
a)Directly under WEB-INF or any subdirectory in WEB-INF
b) If TLD is packaged along with the jar file , then the container expects
the TLD to be present under META-INF or any subdirectory of META-INF
in the jar file under WEB-INF/lib/

If these searches fail, then the container wud try to resolve the URI ( this is the last option the container uses to locate the TLD)
 
Ailsa Cape
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi muthu,

Thank you a lot! According to your instructions, I think my previous second step should be divided into two parts:
a) If the TLD file isn't in a JAR file, the container expects to find it directly under WEB-INF or any subdirectory in WEB-INF.
b) Just as you said, the container searches the implicit taglib map:
b) If TLD is packaged along with the jar file , then the container expects
the TLD to be present under META-INF or any subdirectory of META-INF
in the jar file under WEB-INF/lib/

,and there should be added the third step which is the container will search the JSP file's current directory to find the real TLD file location.
Is it right? Or is this third step equal to your describing?
If these searches fail, then the container wud try to resolve the URI ( this is the last option the container uses to locate the TLD)
Do I understand correctly?

Thanks again!
Best Regards, Ailsa Cape
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic