Preface

Comment

Declaration

Expression

Scriptlet

EL Expression

Directives

Attribute Directive

Include Directive

Page Directive

Tag Directive

Taglib Directive

Variable Directive

Standard Actions

<jsp:attribute>

<jsp:body>

<jsp:element>

<jsp:doBody>

<jsp:forward>

<jsp:getProperty>

<jsp:include>

<jsp:invoke>

<jsp:output>

<jsp:plugin>

<jsp:root>

<jsp:setProperty>

<jsp:text>

<jsp:useBean>

<jsp:output>

Specifies the XML declaration or the document type declaration in the request output of a JSP document or a tag file that is in XML syntax.

XML Syntax

<jsp:output ( omit-xml-declaration="yes|no|true|false" ) 	
   { doctypeDecl } />
   doctypeDecl ::= ( doctype-root-element="rootElement"
   doctype-public="PubidLiteral"
   doctype-system="SystemLiteral" )
   | ( doctype-root-element="rootElement"  	
      doctype-system="SystemLiteral" )

Examples

Here is an example of specifying a document type declaration with jsp:output:

<jsp:output doctype-root-element="books"	
   doctype-system="books.dtd" /> 

The resulting output is:

<!DOCTYPE books SYSTEM "books.dtd" > 

Description

The jsp:output element specifies the XML declaration or the document type declaration in the request output of the JSP document.

The XML declaration and document type declaration that are declared by the jsp:output element are not interpreted by the JSP container. Instead, the container simply directs them to the request output.

Generating a Document Type Declaration

A document type declaration (DTD) defines the structural rules for the XML document in which the document type declaration occurs. XML documents are not required to have a DTD associated with them.

Specifying the document type declaration in the jsp:output element will not cause the JSP container to validate the JSP document against the DTD.

If you want the JSP document to be validated against the DTD, you must manually include the document type declaration within the JSP document, just as you would with any XML document.

Generating XML Declarations

Here is an example of an XML declaration:

<?xml version="1.0" encoding="UTF-8" ?> 

This declaration is the default XML declaration. It means that if the JSP container is generating an XML declaration, this is what the JSP container will include in the output of your JSP document.

Neither a JSP document nor its request output is required to have an XML declaration. In fact, if the JSP document is not producing XML output then it shouldn't have an XML declaration.

The JSP container will not include the XML declaration in the output when either of the following is true:

The JSP container will include the XML declaration in the output when either of the following is true:

The jsp:output element has three attributes that you use to generate the document type declaration:

The rules for using the attributes are as follows:

Attributes

See Also



宏飞网络是你学习web开发、测试web程序实例、和培养职业技能的首选网站。我们提供例子也许有些简单,但对理解基本概念有帮助。

我们尽量避免在教程、参考及例子中出现错误,但不能保证所有的内容都是正确的。

你使用本网站时,我们默认你已经阅读并接受了我们的隐私政策。

Copyright 2003-2011宏飞网络 版权所有