Intermediate JSP Sample : JSP 1.2 XML Syntax Support Tutorial

Previous Contents Next

JSP 1.2 XML Syntax Support

Contents

Purpose

This tutorial sample illustrates JSP 1.2 XML syntax (called JSP XML Documents) along with suitable examples. All the JSP pages in this tutorial sample are written using the XML Syntax.

Remarks

Traditional JSP constructs, such as <%@ page...> directives, <%@ include... > directives, <%...%> for scriptlets, <%!...%> for declarations, and <%=...%> for expressions, are not syntactically valid within an XML document. The JavaServer Pages Specification, Version 1.2 offers more complete support for XML-compatible JSP syntax, adding features and requiring support by compliant JSP containers. In addition, under the JSP 1.1 specification, one could intermix traditional syntax and XML-alternative syntax within a page. This is not true in a JSP 1.2 environment.

The term JSP XML document (called JSP document in the JSP 1.2 specification) refers to a JSP page that uses this XML-compatible syntax. The syntax includes, among other things, a root element and elements that serve as alternatives to JSP directives, declarations, expressions, and scriptlets. A JSP XML document is well formed in pure XML syntax, and is namespace-aware. It uses XML namespaces to specify the JSP XML core syntax and the syntax of any custom tag libraries used. A traditional JSP page, by contrast, is typically not an XML document.

Code from Root.jsp

<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="1.2">
<p>
<span class="about">
<![CDATA[ <jsp:root> Tag ]]>
</span> ...
<![CDATA[
<jsp:root
xmlns:jsp="http://java.sun.com/JSP/Page"
[ xmlns:taglibPrefix="URI" ]+ ...
version="1.2">
JSP Page
</jsp:root>]]>
...
<![CDATA[
<jsp:root
xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:public="http://www.oracle.com/tags"
version="1.2">
<public:otherjsptag>
...
</public:otherjsptag>
</jsp:root>]]>
</p>
</jsp:root>

 

Source Code Listings


Previous Contents Next
E-mail this page
Printer View Printer View
Oracle Is The Information Company About Oracle | Oracle RSS Feeds | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Privacy