This isn't a "misleading" question - it's a small but simple thing to test. For example, I mention this on p.275 of my book:
The body content in each of these elements should be valid Java code, as would appear in the JSP scripting elements, except to ensure the document is well-formed XML you should use a CDATA section or replace & and < characters with the entity references & and < respectively.
I also make reference to it with operators such as <= in EL (use "le" instead). Without giving too much away, there's also a couple of test questions along these lines. [ July 22, 2006: Message edited by: Charles Lyons ]
Charles Lyons (SCJP 1.4, April 2003; SCJP 5, Dec 2006; SCWCD 1.4b, April 2004)
Author of OCEJWCD Study Companion for Oracle Exam 1Z0-899 (ISBN 0955160340 / AmazonAmazon UK )
So the <h1> tag here is legal without being enclosed by <jsp:text> ? I thought template text should all be enclosed by <jsp:text>. Someone help me out here?
Joined: Mar 27, 2003
The <h1> is perfectly valid... this is probably because the JSP document isn't associated with any particular DTD or Schema (although it has a namespace), so the document content isn't restricted. However, it should be well formed, which is where <jsp:text> comes in - this is useful for fragments of documents which otherwise wouldn't be valid. For example:However, in practise the <jsp:text> isn't required as this will also work okay in a JSP document*:Note that nearly all cases where a CDATA would be used in a document are unnecessary if EL is used:which is a valid document (and the primary reason why EL is used).
* For a JSP page, the <jsp:text> is required for this example to work correctly; having the CDATA alone will just cause the CDATA to be output to be the client. However, this would all be unnecessary for a page, because a page doesn't need to be well-formed anyway. [ July 23, 2006: Message edited by: Charles Lyons ]