Howdy Ranchers!
In Charles Lyons book, "SCWCD Study Companion" in Chapter 12, Question 18 you can read:
What is the result of compiling and executing this JSP document? (choose one):
A. The text 'Application title: ' followed by the value of the context parameter title is written to the response.
B. The text 'Application title: ${ context['title'] }' is written to the response.
C. The text '<![CDATA[Application title: ${ context['title'] }]]>' is written to the response.
D. A translation error occurs.
The given answer is
B.
I've tested this kind of example in
Tomcat 6 (and in Tomcat 7 by the way) and it gives me the '
Application title: ' result.
Isn't the EL parser running
before the code is translated into an XML View? I mean, isn't the EL executed before the CDATA can do its work?
In my opinion none of the answers are correct, as the A (which was my choice) is not correct because of the "context parameter title". The context (init) parameters can be read through
initParam map - not context map, right?
By the way, when I try to type the exact code as written, I am not able to run it. I guess it's because the old <
jsp:root...> element. If I change it to the <html ...> it runs fine, i.e.:
is OK, but
is giving me an XML parsing error: syntax error in line 1, column 1:
test:
^
Cheers!