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.
<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" )
Here is an example of specifying a document type declaration with jsp:output:
<jsp:output doctype-root-element="books" doctype-system="books.dtd" />
<!DOCTYPE books SYSTEM "books.dtd" >
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.
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.
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:
omit-xml-declaration
attribute of the jsp:output
element to either true
or yes
.
jsp:root
element in your JSP document, and you do not specify omit-xml-declaration="
false"
in jsp:output
.The JSP container will include the XML declaration in the output when either of the following is true:
omit-xml-declaration
attribute of the jsp:output
element to either false
or no
.
jsp:root
action in your JSP document, and you do not specify the omit-xml-declaration
attribute in jsp:output
.
The jsp:output
element has three attributes that you use to generate the document type declaration:
doctype-root-element
: Indicates the root element of the XML document
doctype-system
: Indicates the URI reference to the DTDdoctype-public
: A more flexible way to reference the DTD. This identifier gives more information about the DTD without giving a specific location. A public identifier resolves to the same actual document on any system even though the location of that document on each system may vary. See the XML 1.0 specification for more information.The rules for using the attributes are as follows:
doctype-root
attribute must be specified if the doctype-system
attribute is specifieddoctype-public attribute
must not be specified unless doctype-system
is specifiedomit-xml-declaration="yes | no | true | false"
doctype-root-element="
rootElement"
doctype-system="
SystemLiteral"
doctype-public="
PubidLiteral"