I'm really not sure about this: does using "JSP Document" / "JSP in XML notation" imply outputting XHTML?
It at least implies consuming and producing well formed XML. If you write invalid XML, then it will error during parsing. If it produces well formed XML, then it can impossibly be HTML4 because closing shorttags like br
, hr
, meta
and link
is disallowed.
What would you recommend to serve when using JSP Document? transitional? strict? HTML5 XML? HTML5 HTML? (HTML5 allows closing tags like <br/>
)
Since it's well formed XML, you should choose either XHTML or HTML5. While HTML5 specification is still in draft mode, it allows closing shorttags. Also see the end of chapter 3.2.2 Elements:
Some elements, however, are forbidden from containing any content at all. These are known as void elements. In HTML, the above syntax cannot be used for void elements. For such elements, the end tag must be omitted because the element is automatically closed by the parser. Such elements include, among others, br
, hr
, link
and meta
HTML Example:
<link type="text/css" rel="stylesheet" href="style.css">
In XHTML, the XML syntactic requirements dictate that this must be made explicit using either an explicit end tag, as above, or the empty element syntax. This is achieved by inserting a slash at the end of the start tag immediately before the right angle bracket.
Example:
<link type="text/css" href="style.css"/>
Authors may optionally choose to use this same syntax for void elements in the HTML syntax as well. Some authors also choose to include whitespace before the slash, however this is not necessary. (Using whitespace in that fashion is a convention inherited from the compatibility guidelines in XHTML 1.0, Appendix C.)
Then, the choice between transitional and strict depends on the degree of web standards you'd like to support. For that, the table at the bottom of this website gives an excellent overview.
To start, you'd like to avoid the Quirks Mode as much as possible since that triggers the box model bug in MSIE browser which causes inconsitenties in margins, paddings, dimensions of the elements when specified by CSS. The lack of the doctype or an incorrect doctype will trigger this mode.
I strongly recommend to pick a Strict doctype since the box model and behaviour would then be as much as possible consistent among the different webbrowsers the world is aware of. Either of the following doctypes is okay, depending on what elements/attributes you'd like to support/vaildate.
XHTML 1.0 strict:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
or the newer XHTML 1.1 (strict, module-based):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
or the (still in draft mode) HTML5 doctype:
<!DOCTYPE html>
Note that you need to ensure that the HTTP Content-Type
header is set to text/html
, not application/xml
nor application/xhtml+xml
when going for XHTML, else MSIE may still go mad since it doesn't support that. Also see the aforementioned doctype website for more detail. The same article indeed mentions that serving XHTML as text/html
is considered harmful, but that only applies when it get rendered with the <?xml?>
declaration and/or contains inline JavaScripts not embedded in CDATA
blocks.