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