<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" />
<!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:
- You have a
jsp:rootelement in your JSP document, and you do not specifyomit-xml-declaration="false"injsp:output.
The JSP container will include the XML declaration in the output when either of the following is true:
- You do not have a
jsp:rootaction in your JSP document, and you do not specify theomit-xml-declarationattribute injsp:output.
The jsp:output element has three attributes that you use to generate the document type declaration:
doctype-system: Indicates the URI reference to the DTD
doctype-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:
- The
doctype-rootattribute must be specified if thedoctype-systemattribute is specified
- The
doctype-public attributemust not be specified unlessdoctype-systemis specified
Attributes
doctype-root-element="rootElement"
- Must be specified if and only if doctype-system is specified or a translation error must occur. Indicates the name that is to be output in the generated DOCTYPE declaration.
- Must be specified if and only if doctype-system is specified or a translation error must occur. Indicates the name that is to be output in the generated DOCTYPE declaration.
doctype-system="SystemLiteral"
doctype-public="PubidLiteral"
