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.

Creating a JSP Document<br />

■ Nested inside a jsp-config element is a jsp-property-group element, which identifies the<br />

JSP page as an XML document. See “Identifying the JSP Document to the Container” on<br />

page 198 for more information.<br />

Creating a JSP Document<br />

186<br />

A JSP document is an XML document and therefore must comply with the XML standard.<br />

Fundamentally, this means that a JSP document must be well formed, meaning that each start<br />

tag must have a corresponding end tag and that the document must have only one root element.<br />

In addition, JSP elements included in the JSP document must comply with the XML syntax.<br />

Much of the standard JSP syntax is already XML-compliant, including all the standard actions.<br />

Those elements that are not compliant are summarized in Table 6–1 along with the equivalent<br />

elements in XML syntax. As you can see, JSP documents are not much different from JSP pages.<br />

If you know standard JSP syntax, you will find it easy to convert your current JSP pages to XML<br />

syntax and to create new JSP documents.<br />

TABLE 6–1 Standard Syntax Versus XML Syntax<br />

Syntax Elements Standard Syntax XML Syntax<br />

Comments <br />

Declarations .. <br />

Directives <br />

<br />

xmlns:prefix="tag library URL"<br />

Expressions .. <br />

Scriptlets .. <br />

To illustrate how simple it is to transition from standard syntax to XML syntax, let’s convert a<br />

simple JSP page to a JSP document. <strong>The</strong> standard syntax version is as follows:<br />

<br />

<br />

<br />

Hello<br />

<br />

<br />

My name is Duke. What is yours?<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!