10.12.2012 Views

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Identifying the JSP Document to the Container<br />

Directing the document type declaration to output without interpreting it is useful in situations<br />

when another system receiving the output expects to see it. For example, two companies that do<br />

business by means of a web service might use a standard DTD, against which any XML content<br />

exchanged between the companies is validated by the consumer of the content. <strong>The</strong> document<br />

type declaration tells the consumer what DTD to use to validate the XML data that it receives.<br />

For the JSP container to validate books.jspx against book.DTD, you must manually include the<br />

document type declaration in the books.jspx file rather than use jsp:output. However, you<br />

must add definitions for all tags in your DTD, including definitions for standard elements and<br />

custom tags, such as jsp:useBean and c:forEach. You also must ensure that the DTD is<br />

located in the domain-dir/config/ directory so that the JSP container will validate the JSP<br />

document against the DTD.<br />

Identifying the JSP Document to the Container<br />

198<br />

A JSP document must be identified as such to the web container so that the container interprets<br />

it as an XML document. <strong>The</strong>re are three ways to do this:<br />

■ In your application’s web.xml file, set the is-xml element of the jsp-property-group<br />

element to true.<br />

■ Use a <strong>Java</strong> Servlet Specification version 2.4 web.xml file and give your JSP document the<br />

.jspx extension.<br />

■ Include a jsp:root element in your JSP document. This method is backward-compatible<br />

with JSP 1.2.<br />

<strong>The</strong> <strong>Java</strong> <strong>EE</strong> 5<strong>Tutorial</strong> • June 2010

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!