Generating a DOCTYPE Declaration
Because the page in Example 17-10 generates an XHTML
response, the response body should start with a DOCTYPE declaration
for XHTML. This is not a JSP specification requirement, but for XML
documents defined by a DTD or an XML Schema, it’s
always a good idea. The <jsp-output> action
with the doctype-root-element,
doctype-public, and
doctype-system attributes adds a DOCTYPE
declaration based on the attribute values at the top of the response
body. With the attribute values used in Example 17-10,
the generated declaration looks like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
The doctype-public attribute is optional. If you
omit it, the action generates a declaration without a public
identifier.
Note that if you include a DOCTYPE declaration that specifies a DTD in the JSP Document itself, it applies to the JSP Document, not to the generated response. In this case, the container validates the JSP Document against the specified DTD.
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