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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

To illustrate this, here is an example of specifying a document type declaration with<br />

jsp:output:<br />

<br />

<strong>The</strong> resulting output is:<br />

<br />

Specifying the document type declaration in the jsp:output element will not cause the JSP<br />

container to validate the JSP document against the books.dtd.<br />

If you want the JSP document to be validated against the DTD, you must manually include the<br />

document type declaration within the JSP document, just as you would with any XML<br />

document.<br />

Table 6–3 shows all the jsp:output attributes. <strong>The</strong>y are all optional, but some attributes<br />

depend on other attributes occurring in the same jsp:output element, as shown in the table.<br />

<strong>The</strong> rest of this section explains more about using jsp:output to generate an XML declaration<br />

and a document type declaration.<br />

TABLE 6–3 jsp:output Attributes<br />

Attribute What It Specifies<br />

omit-xml-declaration A value of true or yes omits the XML declaration. A value of false or no<br />

generates an XML declaration.<br />

doctype-root-element Indicates the root element of the XML document in the DOCTYPE. Can be specified<br />

only if doctype-system is specified.<br />

doctype-system Specifies that a DOCTYPE is generated in output and gives the SYSTEM literal.<br />

doctype-public Specifies the value for the Public ID of the generated DOCTYPE. Can be specified<br />

only if doctype-system is specified.<br />

Generating XML Declarations<br />

Here is an example of an XML declaration:<br />

<br />

Creating a JSP Document<br />

This declaration is the default XML declaration. It means that if the JSP container is generating<br />

an XML declaration, this is what the JSP container will include in the output of your JSP<br />

document.<br />

Neither a JSP document nor its request output is required to have an XML declaration. In fact, if<br />

the JSP document is not producing XML output then it shouldn’t have an XML declaration.<br />

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

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

Saved successfully!

Ooh no, something went wrong!