Identifying a JSP Document
The container needs help to recognize a JSP page as a page using the XML syntax. A JSP 2.0 container follows these rules, in this order:
The requested page has an extension matching the URL pattern of a JSP group declaration in the web.xml file with
<is-xml>set totrue, as described earlier.The requested page has the .jspx extension, unless this extension has been disabled by a JSP group with
<is-xml>set tofalse. For a tag file in XML syntax, the .tagx extension must be used.The requested page is identified as a JSP page (through the default .jsp extension or an extension defined by a JSP group declaration) and its root element is
<jsp:root>.
The third rule was the only one supported by JSP 1.2, as I mentioned earlier, and it’s primarily kept for backward compatibility. For new applications, you probably want to rely on one of the first two rules instead.
Let’s use a simple JSP Document to discuss the syntax requirements in more detail. Example 17-10 shows a JSP Document that illustrates most of the things you need to consider, as well as the main features available for this format.
<html xmlns="http://www.w3c.org/1999/xhtml" xmlns:jsp="http://java.sun.com/JSP/Page" xml:lang="en" lang="en"> <jsp:output doctype-root-element="html" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3c.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/> <jsp:directive.page contentType="text/html" /> ...Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access