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.

This syntax notation summarizes these rules:<br />

<br />

doctypeDecl:= (doctype-root-element="rootElement"<br />

doctype-public="PublicLiteral"<br />

doctype-system="SystemLiteral")<br />

| (doctype-root-element="rootElement"<br />

doctype-system="SystemLiteral")<br />

Suppose that you want to reference a DTD, called books.DTD, from the output of the<br />

books.jspx page. <strong>The</strong> DTD would look like this:<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

To add a document type declaration that references the DTD to the XML request output<br />

generated from books.jspx, include this jsp:output element in books.jspx:<br />

<br />

With this jsp:output action, the JSP container generates this document type declaration in the<br />

request output:<br />

<br />

Creating a JSP Document<br />

<strong>The</strong> jsp:output need not be located before the root element of the document. <strong>The</strong> JSP<br />

container will automatically place the resulting document type declaration before the start of<br />

the output of the JSP document.<br />

Note that the JSP container will not interpret anything provided by jsp:output. This means<br />

that the JSP container will not validate the XML document against the DTD. It only generates<br />

the document type declaration in the XML request output. To see the XML output, run<br />

http://localhost:8080/books/books.jspx in your browser after you have updated<br />

books.WAR with books.DTD and the jsp:output element. When using some browsers, you<br />

might need to view the source of the page to actually see the output.<br />

Chapter 6 • <strong>Java</strong>Server Pages Documents 197

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

Saved successfully!

Ooh no, something went wrong!