tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: Tomcat 8 jspx and HTML5
Date Sun, 09 Aug 2015 14:32:56 GMT
Hash: SHA256


On 8/8/15 8:54 AM, Konstantin Prei├čer wrote:
> Hi Christopher,
>> -----Original Message----- From: Christopher Schultz
>> [] Sent: Saturday, August 8,
>> 2015 2:32 PM
>> This is a common problem, and the reason for it is that <script>
>> for some reason, in every browser I've ever seen, completely
>> fails to parse correctly if it's a self-terminating tag like
>> <script />. When you use .jspx, the input and output are assumed
>> to be both well-formed XML where <script /> is perfectly
>> acceptable.
>> IMO this is a problem with browsers. Even in
>> standards-compliance mode, they seem to demand that <script> be a
>> paired tag. Thus, all of our script tags that reference external
>> files are written like this:
>> <script src="(script)" type="text/javascript"><!-- --></script>
>> This will force the XML serializer to retain the comment and
>> force a paired tag.
> Can you elaborate why you think this is a problem with browsers?
> The W3 HTML5 specification says at section 4.11.1 [1] for the
> <script> element:
> Tag omission in text/html: Neither tag is omissible
> I read it so that when using HTML syntax (text/html), you cannot
> omit the end element of a <script> tag. Section 8.1.2 (Elements)
> [2] also doesn't seem to allow a self-closing tag for <script>
> elements.

Agreed. My experience is that even when using application/xhtml+xml,
the browser still demands that both parts of the tag appear. It's been
a while since I've bothered re-investigating the situation, since it's
just easier to standardize on <script><!-- --></script> and have it
work everywhere.

> However, you can use the XML syntax instead the HTML syntax for 
> serializing HTML5, which means using a Content-Type of 
> "application/xhtml+xml". When using this content type, a browser 
> supporting HTML5 (including IE 9+) will use an XML parser, so a 
> syntax like <script /> will work on such documents.

True, but older browsers are usually not compliant. Our application
needs to support some stinky older browsers, so we unfortunately have
to support the lowest common denominator (like usual with the web).

> (The problem with XML syntax however is that there are some 
> JavaScript libraries that don't seem to be aware that there's an
> XML syntax of HTML5 and will not work correctly, e.g. jQuery Mobile
> up to version 1.4.5.)

I wasn't aware of that; I was under the impression that jQuery
operated on the DOM tree which has already been parsed by the browser.

- -chris
Comment: GPGTools -


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message