aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Parents of Simple - Classic tags 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 "Parents of Simple - Classic tags " Watch "Parents of Simple - Classic tags " New topic
Author

Parents of Simple - Classic tags

Paul Bartels
Greenhorn

Joined: Jun 16, 2008
Posts: 11

Studying the excellent Head First Servlets and JSP book and am having a little trouble with one of the Coffee Cram questions...

Chaper 10 Custom Tag Development
Mock Exam Chapter 10

Question 17

Given a tag, simpleTag, whose handler is implemented using the Simple tag model and a tag, complexTag, whose handler is implemented using the Classic tag model.
Both tags are declared to be non-empty in the TLD.

Which JSP code snippets are valid uses of this tag? (Choose all that apply)

A. <my:simpleTag>
<my:complexTag />
</my:simpleTag>


B. <my:simpleTag>
<%= displayText %>
</my:simpleTag>

C. <my:simpleTag>
<%@ include file="/WEB-INF/web/common/headerMenu.html" %>
</my:simpleTag>

D. <my:simpleTag>
<my:complexTag>
<% i++; %>
</my:complexTag>
</my:simpleTag>

----------------------------------------
A and C are correct.

Option A seems to be a classic tag with a simple parent.
Page 540 of the text leads off with the bold title:
"Simple tags can have Classic parents"
before going onto explain that using the getParent() method a classic tag can access classic tag parents and a simple tag can access either a classic or simple parent.

Should A be incorrect as it's a classic tag with a simple parent?


SCJP5 SCWCD
Vishwanath Krishnamurthi
Ranch Hand

Joined: Jun 04, 2007
Posts: 331
A is correct, because Simple Tags can have in their body, Classic Tags as long as the Classic Tags don't have any scriptlets... (as explained in answers for that option in 2nd ed. book)

And by my understanding, Simple Tags can have Simple or Classic Tag as a parent and vice versa...
But it is while getting the reference to the parent tag using getParent() method where the issue arises.
( That SimpleTags can use the getParent() method to get the reference of either a SimpleTag or a Classic Tag and Classic Tag can use the getParent() to access only Classic Tag parents)


Blog
Paul Bartels
Greenhorn

Joined: Jun 16, 2008
Posts: 11

OK. Understood.

So,ClassicTags can have either parent (without using the TagAdapter class), as long as they don't interact - specifically, that getParent() or maybe findAncestorWithThisClass() isn't used.

Thanks a lot!
namita sasa
Ranch Hand

Joined: Apr 20, 2009
Posts: 56
The body-content is defined as non-tagdependent that means we can have scriplets, EL and tags allowed. I am confused!
Please help.
namita sasa
Ranch Hand

Joined: Apr 20, 2009
Posts: 56
Please let me know the correct answer. HFSJ says that tagdependent means body would be treated as plain text. Here body is declared as non-tagdependent i.e. it should allow scriplets and EL?? Then B and D are also correct choices.
Paul Bartels
Greenhorn

Joined: Jun 16, 2008
Posts: 11

The errata for the first edition states:

Both tags are declared to be non-empty in the TLD.
should read:
Both tags are declared to be non-empty and non-tag dependent in the TLD.
John Wallace
Greenhorn

Joined: May 02, 2006
Posts: 17
namita sasa wrote:The body-content is defined as non-tagdependent that means we can have scriplets, EL and tags allowed. I am confused!
Please help.


Not sure what your question is.

John Wallace - SCJP, SCWCD, ZCE 5.3
namita sasa
Ranch Hand

Joined: Apr 20, 2009
Posts: 56
I am confused about the meaning of non-tag dependent. Does it mean that scriplets and EL and tags are allowed?
rachna jain
Ranch Hand

Joined: Jul 14, 2009
Posts: 74
tagdependent means no EL ,no scriplet only plain text

correct me if i am wrong


Rachna Jain

SCWCD 1.5
namita sasa
Ranch Hand

Joined: Apr 20, 2009
Posts: 56
That means non-tag dependent indicates scriplets, EL, tags allowed if tagdependent means no scriplets, no EL, no tags??
rachna jain
Ranch Hand

Joined: Jul 14, 2009
Posts: 74
yes it should be as per my understanding it would be gud if you can share a question where it is used.
rachna jain
Ranch Hand

Joined: Jul 14, 2009
Posts: 74
oops.........

are you refering question 17 on page 587

yes in this question i think its little tricky as simple tags never have scriplets or we can say simple tags dnt have JSP(tagdependent ) body

so option B,D is wrong and scrptless can have EMPTY BODY so A is write
namita sasa
Ranch Hand

Joined: Apr 20, 2009
Posts: 56
This is regarding same question Chaper 10 Custom Tag Development
Mock Exam Chapter 10 , Question 17. Paul who started this topic mentioned that the choces are A and C. My question is why not B and C also valid?
namita sasa
Ranch Hand

Joined: Apr 20, 2009
Posts: 56
Thanks again Rachana. I did not know about that point. I saw one more thread which explained about that. Now it is clear. Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Parents of Simple - Classic tags