I’m really not sure about this: does using “JSP Document” / “JSP in XML notation” imply outputting XHTML?
If so, is there anything special to look after as to produce a “valid” XHTML page?
More specifically: can I have a valid “JSP Document” (JSP in XML) that is producing an invalid XHTML page?
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,metaandlinkis disallowed.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:
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:
or the newer XHTML 1.1 (strict, module-based):
or the (still in draft mode) HTML5 doctype:
Note that you need to ensure that the HTTP
Content-Typeheader is set totext/html, notapplication/xmlnorapplication/xhtml+xmlwhen 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 astext/htmlis considered harmful, but that only applies when it get rendered with the<?xml?>declaration and/or contains inline JavaScripts not embedded inCDATAblocks.