background image

Identifying the JSP Document to the Container

<< Rules for Using the Attributes | JavaServer Pages Standard Tag Library >>
<< Rules for Using the Attributes | JavaServer Pages Standard Tag Library >>

Identifying the JSP Document to the Container

the document type declaration in the XML request output. To see the XML output, run
http://localhost:8080/books/books.jspx
in your browser after you have updated
books.WAR
with books.DTD and the jsp:output element. When using some browsers, you
might need to view the source of the page to actually see the output.
Directing the document type declaration to output without interpreting it is useful in situations
when another system receiving the output expects to see it. For example, two companies that do
business by means of a web service might use a standard DTD, against which any XML content
exchanged between the companies is validated by the consumer of the content. The document
type declaration tells the consumer what DTD to use to validate the XML data that it receives.
For the JSP container to validate books.jspx against book.DTD, you must manually include the
document type declaration in the books.jspx file rather than use jsp:output. However, you
must add definitions for all tags in your DTD, including definitions for standard elements and
custom tags, such as jsp:useBean and c:forEach. You also must ensure that the DTD is
located in the domain-dir/config/ directory so that the JSP container will validate the JSP
document against the DTD.
Identifying the JSP Document to the Container
A JSP document must be identified as such to the web container so that the container interprets
it as an XML document. There are three ways to do this:
In your application's web.xml file, set the is-xml element of the jsp-property-group
element to true.
Use a Java Servlet Specification version 2.4 web.xml file and give your JSP document the
.jspx
extension.
Include a jsp:root element in your JSP document. This method is backward-compatible
with JSP 1.2.
Identifying the JSP Document to the Container
The Java EE 5 Tutorial · September 2007
200