File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Confusing Tag-directive 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 "Confusing Tag-directive" Watch "Confusing Tag-directive" New topic

Confusing Tag-directive

madhup narain
Ranch Hand

Joined: Dec 14, 2004
Posts: 148
Given -

has been placed in /WEB-INF/mytlds/tld1.tld

is invoked using <mytags:tag1 />

whats is the correct tag directive for this ?

1. <%@ taglib prefix="mytags" uri="/WEB-INF/mytlds/tld1.tld" %>
2. <%@ taglib prefix="mytags" uri="" %>

I always asumed that the uri in the directive MUST match with the uri in the tld, therefore choose 2nd one but seems like its incorrect and the 1st one is correct.
I havent been able to convince my self, can someone help me out ?

Money for nothing and Java for Free
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63865

Using the URI defined by the TLD is the best approach.

[Asking smart questions] [About Bear] [Books by Bear]
Rajeev Rnair
Ranch Hand

Joined: Mar 22, 2010
Posts: 308

Second one is wrong URI
where as TLD is showing

SCJP6, SCWCD5, OCP-JBCD5, OCE-JWSD6 OCE-JPAD6 , OCM-JEA5 1,OCM-JEA5 2,3 - Brainbench certifications: J2EE, Java2, Java2-NonGUI, JSP, SQL2000 Admin, SQL2000 Programming , Brainbench certified Java Programmer, Computer Programmer, Web Developer, Database Administrator
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper

Joined: Apr 07, 2010
Posts: 2099

Hi Madhup,

Both Bear and Rajeev are correct here, but the explanation why

is allowed here is found in the specifications (jsp2.0)
JSP. Computing TLD Locations
[removed... just have a look at this part later..]
Finally, the fallback rule allows a taglib directive to refer directly to the TLD.
This arrangement is very convenient for quick development at the expense of less
flexibility and accountability.

I agree. Here's the link:
subject: Confusing Tag-directive
It's not a secret anymore!