This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tag File Mock Question

 
Alec Lee
Ranch Hand
Posts: 569
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Nicky Eng
Ranch Hand
Posts: 378
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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 %>?
 
Srinivasan Rengan
Ranch Hand
Posts: 122
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think A,B and E are correct choices here.

Any objections to this Friends!

Srini
 
George Bromfield
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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 ??
 
shanthisri mocherla
Ranch Hand
Posts: 119
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can nayone please let me know which are correct answers for the above question??
please.

thanks shanthi
 
Ranjani Theyagarajan
Greenhorn
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so the answer should be B and E.
 
Narendra Dhande
Ranch Hand
Posts: 951
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

My answers also B and E.
 
Jesse Fouse
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic