On 8 August 2015 at 06:54, Konstantin Preißer <kpreis...@apache.org> wrote:

> Hi Christopher,
>
> > -----Original Message-----
> > From: Christopher Schultz [mailto:ch...@christopherschultz.net]
> > 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.
>
>
So it seems that it's well known that the <script> tag can't be
self-closing for HTML.
When I added the JSP directive and the jsp:output to indicate that I wanted
HTML I kind of expected to get valid HTML.

I couldn't find it in the JSP specification but the JEE tutorial indicates
that the JSP container doesn't interpret the document type declaration
indicated with jsp:output.  So Tomcat doesn't need to adjust the output
based on those declarations.

I'm bringing all this up because, at work, I'm in the middle of migrating
from weblogic to tomcat.  A lot of our JSP files have needed changes to put
in empty comment bodies to get around this behaviour.  We've found that
script, div and span can cause problems when they are self-closing.  We've
fixed most of our source code but we feel a little vulnerable where the
simple removal of a comment can cause a page to break.

I've looked into the Generator class in Tomcat and it produces the output
directly - i.e., it doesn't use a tool like SAX.
It probably wouldn't be difficult to put in a couple of special cases to
output closing tags with empty contents for a few elements.  Actually, we
could just remove the test for a null body and always produce the closing
tag (and empty body) which would simplify the code slightly and solve my
problem.  It would still be valid XML and it would have the benefit of
being valid HTML as well.

Would such a change stand much of a chance at being accepted by the
community?

I've ready the complete thread by now and really appreciate the feedback
and discussion the two of you have given.

Thanks,
Kevin.

Reply via email to