• 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

Tag File Mock Question

 
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A web application contains a tag file called beta.tag in/WEB-INF/tags/alpha.
A JSP page called sort.jsp exists in the web application and contains only this JSP code:
1. <%@ taglib prefix="x"
2. tagdir="/WEB-INF/tags/alpha" %>
3. <x:beta />
The sort.jsp page is requested.
Which two are true? (Choose two.)
A. Tag files can only be accessed using a tagdir attribute.
B. The sort.jsp page translates successfully and invokes the tag defined by beta.tag.
C. The sort.jsp page produces a translation error because a taglib directive must always have a uri attribute.
D. Tag files can only be placed in /WEB-INF/tags, and NOT in any subdirectories of /WEB-INF/tags.
E. The tagdir attribute in line 2 can be replaced by a uri attribute if a TLD referring to beta.tag is created and added to the web application.

This involves some knowledge not directly described by HFSJ.
 
Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
tagdir? gosh...i didn't know that.

tagdir is used to refer to the location of the tag file?

uri is optional ?
 
Alec Lee
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As I said, this is not described in HFSJ. Consider this, if the tag file is placed inside a jar file under /WEB-INF/lib/, what is required to invoked such a tag file? Should tagdir used in <%@ taglib %>?
 
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think A,B and E are correct choices here.

Any objections to this Friends!

Srini
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think that if you have a tld where you declare the tag file then you can use the taglib directive with the uri of that tld.

quote from HFSJ : "if you make a tld that references your tag files, the container will consider both tag files and custom tags mentioned in the same tld as belonging to the same library"

Correct answers in my opinion: B and E
 
Nicky Eng
Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Srinivasan R:
I think A,B and E are correct choices here.

Any objections to this Friends!

Srini



A. Tag files can only be accessed using a tagdir attribute.

option A is NOT correct. it is not the only way to access tag file using a tagdir attribute. There is another way, using uri attribute in taglib directive and then Container will automatically map to the tag file to find the appropriate uri match in the tld.

correct me if i'm wrong.

this tagdir bring confusion with uri...???what if we put uri and tagdir in the same time ??
 
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can nayone please let me know which are correct answers for the above question??
please.

thanks shanthi
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The syntax given in spec is

<%@ taglib (uri="tagLibraryURI"|tagdir="tagDir") prefix="tagPrefix" %>

where

uri can be either an absolute URI or a relative URI which should be unique.

tagdir -- It should be an absolute path start with /WEB_INF/...
A translation error occur if the value does not point to a directory exists.

When both(uri and tagdir) are used together a translation error would occur...

Hope this is clear...
 
Ranjani Theyagarajan
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so the answer should be B and E.
 
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

My answers also B and E.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would choose B and E.

But you can easily write code to test this in Tomcat to be 100% sure.
 
reply
    Bookmark Topic Watch Topic
  • New Topic