This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Tag File Mock Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Tag File Mock Question" Watch "Tag File Mock Question" New topic
Author

Tag File Mock Question

Alec Lee
Ranch Hand

Joined: Jan 28, 2004
Posts: 569
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

Joined: Mar 26, 2005
Posts: 378
tagdir? gosh...i didn't know that.

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

uri is optional ?


From NickyEng
Diploma in Computer Studies
SCJP 1.4
SCWCD 1.4
Formula 1 app by Maxis (Playbook)
Alec Lee
Ranch Hand

Joined: Jan 28, 2004
Posts: 569
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

Joined: Nov 07, 2004
Posts: 122
I think A,B and E are correct choices here.

Any objections to this Friends!

Srini


SCJP, SCWCD, SCBCD (EJB 2.x and EJB 3), OCA, SCDJWS
George Bromfield
Greenhorn

Joined: Jul 15, 2005
Posts: 12
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

Joined: Mar 26, 2005
Posts: 378
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

Joined: Sep 05, 2005
Posts: 119
Can nayone please let me know which are correct answers for the above question??
please.

thanks shanthi
Ranjani Theyagarajan
Greenhorn

Joined: Feb 08, 2006
Posts: 19
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

Joined: Feb 08, 2006
Posts: 19
so the answer should be B and E.
Narendra Dhande
Ranch Hand

Joined: Dec 04, 2004
Posts: 950
Hi,

My answers also B and E.


Narendra Dhande
SCJP 1.4,SCWCD 1.4, SCBCD 5.0, SCDJWS 5.0, SCEA 5.0
Jesse Fouse
Greenhorn

Joined: Feb 01, 2005
Posts: 5
I would choose B and E.

But you can easily write code to test this in Tomcat to be 100% sure.
 
Consider Paul's rocket mass heater.
 
subject: Tag File Mock Question
 
Similar Threads
taglib-directive tagdir and uri
Taglib and Tagdir question?
Tag Files : why TLD requires
using uri attribute instead of tagdir
Doubt in mocktest