my dog learned polymorphism*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Question about classic tags nesting in the context of body-content Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Question about classic tags nesting in the context of body-content" Watch "Question about classic tags nesting in the context of body-content" New topic
Author

Question about classic tags nesting in the context of body-content

Grzegorz Konczyk
Greenhorn

Joined: Jan 04, 2012
Posts: 1
Hi all,
I'm preparing for my OCPJWCD exam and I've encounter some ambiguities with nesting classic tags with different body-content values.
Here are the specs:

1. my tag class (same class for every tag):

public class MyTag extends TagSupport throws JspException{
public int doStartTag(){
return EVAL_BODY_INCLUDE;
}
}

2. 3 different tags. No tag has any attribute. The difference is in body-content value:

<classicJSP> - this one has <body-content>JSP</body-content>
<classicTag> - this one has <body-content>tagdependent</body-content>
<classicScr> - this one has <body-content>scriptless</body-content>

I've done some different cases with these tags and here is what i've received:

a) <classicJSP><%= 1+2 %></classicJSP> - the result is: 3 (ok with me)
b) <classicTag><%= 1+2 %></classicTag> - the result is: <%= 1+2 %> (ok with me)
c) <classicJSP><classicJSP><%= 1+2 %></classicJSP></classicJSP> - the result is: 3 (ok with me)
d) <classicJSP><classicTag><%= 1+2 %></classicTag></classicJSP> - the result is: <%= 1+2 %> (NOT ok with me)
e) <classicTag><classicJSP><%= 1+2 %></classicJSP></classicTag> - the result is: <%= 1+2 %> (NOT ok with me)
f) <classicScr><classicJSP><%= 1+2 %></classicJSP></classicScr> - the result is: runtime error (ok with me - I guess)
g) <classicScr><classicTag><%= 1+2 %></classicTag></classicScr> - the result is: <%= 1+2 %> (NOT ok with me - relating to point f))

Ad d) I think result here should be 3. Inner <classicTag> produces <%= 1+2 %> and this goes to outer <classicJSP>, and the outer <classicJSP> evaluates this to 3.
Ad e) I think result here also should be 3. Inner <classicJSP> produces 3 and this goes to outer <classicTag>, which produces 3.
Ad f) I think I know that one - the outer <classicScr> see JSP expression inside inner <classicJSP> and this causes exception
Ad g) This related to point f) is mystery for me - why in f) there is exception and here is ok??

I would appreciate any of any of d), e), f)(if my thinking is correct) or g). Thanks very much in advance.
Kind regards,
grzego
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question about classic tags nesting in the context of body-content