You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Mark Abbott <Ma...@openwave.com> on 2001/08/16 23:13:06 UTC

JSP Document parsing

Hi all -

I've noticed a couple of problems with Jasper when processing
JSP documents, that is, JSP pages authored in the XML syntax.
I'm using the tomcat-b7 release.

The documents I've tried contain explicit <jsp:root> elements,
as it seems they ought to.  Unfortunately, the XmlOutputter class
in Jasper, while making an effort to avoid choking on multiple
<jsp:root> elements encountered while processing included
pages, does not handle the case where the outermost containing
page itself contains such an element.

One result is that two </jsp:root> end tags get emitted into the page.
The more subtle issue has to do with the xmlns:jsp and version
attributes on the <jsp:root> start tag.  Jasper inserts hardcoded values 
for those attributes corresponding to the JSP 1.2 release. But in order
to be truly valid, the document itself should contain those attributes
(at least version is required). So two instances of each attribute end up
in the output, causing the resulting XML stream to be invalid when parsed
by, for example, the tag library validator in JSPTL.

Maybe the attributes in the outermost containing page ought to
override any hardcoded defaults Jasper wants to assert? Or maybe Jasper
should report an error if the version attribute in the document doesn't agree
with the JSP version it thinks it is processing?  What do you think?
I may be able to provide diffs for a solution if I was sure what to do.

        Thanks - Mark




Re: JSP Document parsing

Posted by Mark Abbott <Ma...@openwave.com>.
Hi again - since no one voiced an opinion on the right way to 
approach this bug, I've done the simplest possible fix and attached a patch. 

This change will cause Jasper to always emit its own hardcoded values 
for the xmlns:jsp and version attributes of the <jsp:root> tag, ignoring any 
occurrences of those attributes in documents. This makes processing of 
JSP documents consistent whether they were specified in XML or JSP 
syntax. I also made the trivial fix to the double end tag problem.

I suspect that a more elaborate solution might be desirable for the version 
attribute, since if the document says it is version 1.3 (when we have such 
a version), but the compiler only handles 1.2, this ought to indicate a 
problem. But I'm not sure how to do that at this point, so this patch gets 
past the immediate problems that make valid documents unusable.

Cheers - Mark