• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HFSJ final mock exam quetion 54 - taglib and uri

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everybody,

Given a tag library descriptor located at /mywebapp/WEB-INF/tlds/mytags.tld,
which would be the correct taglib directive ? Assume mywebapp is the web
application root and that there are no <taglib> tags in the deployment
descriptor.

A) <%@ taglib uri="/mytags.tld" prefix="my" %>
B) <%@ taglib uri="/tlds//mytags.tld" prefix="my" %>
C) <%@ taglib uri="/WEB-INF/tlds/mytags.tld" prefix="my" %>
D) <%@ taglib uri="/mywebapp/WEB-INF/tlds/mytags.tld" prefix="my" %>
E) /mywebapp/WEB-INF/tlds/mytags.tld is NOT a valid location
for a tag library descriptor, so none of these will work.

The correct answer according to the HFSJ is C stating:

Option C is correct because, in the absence of a <taglib> element
in the DD, the URI must be a full path relative to the application root.

I really don't understand it. Earlier you can read that URI is not
a real path to the tld file and now they write it is. You don't have to
write any <taglib> elements in the DD and it will still work (assuming
there is a tld with matching URI whatever it is and it's in the default
location). Is it a mistake ?

Cheers,

Adrian.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a confusing question. The author replied in this thread.
 
Adrian Sosialuk
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Christophe,

Thanks for your reply.

Yes - I looked through JSP spec and IMHO the question is
wrongly formed.

1) First of all, you don't have to use taglib element in DD at all
2) The important thing is that URI matches, no matter what it is.
So even though you don't have the taglib element in the DD, it doesn't
have to be path.
3) And here the thing that I don't quite understand - you can provide
path to the existing tld file which will work, but why would anybody
do that ? I mean you have to provide URI or path anyway, so unless
someone is lazy and have URI longer than path then that's the only
reason I can see of using that ...


Cheers,

Adrian
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

3) And here the thing that I don't quite understand - you can provide
path to the existing tld file which will work, but why would anybody
do that ?


Using the path is actually useful when using Tag Files, as you don't need to provide a TLD (which means there's no uri either).
 
reply
    Bookmark Topic Watch Topic
  • New Topic