You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Anne and Bill Moore <nz...@bellsouth.net> on 2000/11/23 05:34:45 UTC
More on JSP in XML format
I anm still trying to get my head around JSP in XML format.
Can anyone suggest further reading beyond the JSP Version 1.2 - Proposed
Final Draft (PFD) spec or provide examples.
When I try the examples like those from the spec using Tomcat Version
4.0 Milestone 4, I routinely get a java.lang.ClassCastException:
org.apache.jasper.compiler.ParserXJspSaxHandler$Node.
After some experimentation I was able to get very simple XML formatted
JSP to work, but it seems that whenever the jsp contained a jsp:cdata
element the class cast exception occurs.
It may be that I have misunderstood the jsp:cdata element or is this a
bug in Tomcat?
--
Thanks and Regards
Anne and Bill Moore
nzmoore@bellsouth.net
Remember: Life is too short to drink bad wine!!!
Re: More on JSP in XML format
Posted by Anne and Bill Moore <nz...@bellsouth.net>.
Pierre Delisle wrote:
>
> As "Bap" replied, you must make sure you "escape" content that can be
> interpreted by XML. Remember, this is an XML document that is being
> submitted to an XML parser.
>
> By doing this:
>
> <jsp:scriptlet>
> <![CDATA[
> for(int i=0; i<6; i++)
> out.println(i);
> ]]>
> </jsp:scriptlet>
>
> It should work fine.
>
> > When you asked me to report bugs I was not sure if you mneant for me to
> > enter them to bugrat - I created Bug Report #511 with synopsis
> > "Error in parsing scriptlet when jsp is in xml format " to describe this
> > problem.
>
> Yes, bugrat is the preferred way to submit bug reports. If just submitted
> to the mailing list, they unfortunately run the chance to fall through the
> cracks.
>
> -- Pierre
Pierre and Bap - thanks for the clarification - as you point out the use
of CDATA is what I needed.
Now I finally understand the note in section 5.1.9 of the spec except
the section 5.5 it refers to is missing.
I do appreciate the help - as I said when I started this I dont always
find the spec easy to understand.
--
Thanks and Regards
Anne and Bill Moore
nzmoore@bellsouth.net
Remember: Life is too short to drink bad wine!!!
Re: More on JSP in XML format
Posted by Pierre Delisle <pi...@sun.com>.
Anne and Bill Moore wrote:
> ...
> I have now found a bug with scriplets.
> The < character in a scriptlet are being parsed as if it were markup
> rather than being treated as Java syntax less than symbol.
>
> For example the scriptlet
>
> <%
> for(int i=0; i<6; i++)
> out.println(i);
> %>
>
> works as expected in standard format jsp.
>
> The xml format scriplet shown below produces an exception
> org.apache.jasper.compiler.ParseException The content beginning "<6" is
> not legal markup
>
> <jsp:scriptlet>
>
> for(int i=0; i<6; i++)
> out.println(i);
>
> </jsp:scriptlet>
As "Bap" replied, you must make sure you "escape" content that can be
interpreted by XML. Remember, this is an XML document that is being
submitted to an XML parser.
By doing this:
<jsp:scriptlet>
<![CDATA[
for(int i=0; i<6; i++)
out.println(i);
]]>
</jsp:scriptlet>
It should work fine.
> When you asked me to report bugs I was not sure if you mneant for me to
> enter them to bugrat - I created Bug Report #511 with synopsis
> "Error in parsing scriptlet when jsp is in xml format " to describe this
> problem.
Yes, bugrat is the preferred way to submit bug reports. If just submitted
to the mailing list, they unfortunately run the chance to fall through the
cracks.
-- Pierre
Re: More on JSP in XML format
Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Anne and Bill Moore wrote:
>
> BTW Bugrat seemed to mangle the example scriptlet I entered in the
> problem description and seems to have lost the comment I put in the How
> to reproduce section.
>
BugRat is simply embedding what you type into the HTML page it creates. I have
found it easiest to put
<pre>
... code example ...
</pre>
in the descriptions, and everything comes out in a readable format.
(Hint: If you are looking at a bug report where the originator didn't do this,
click on "view source" and scroll down to that portion of the page -- and the
line breaks will at least be correct :-).
Craig
Re: More on JSP in XML format -- This, is a very excellent post!
Posted by Bap <li...@a1.org.uk>.
Bap wrote:
> "Michael G. Anderson C.T.O" wrote:
>
> > This, is a very excellent post!
> >
> > Anne and Bill Moore wrote:
> >
> > > Pierre Delisle wrote:
> > > I have now found a bug with scriplets.
> > > The < character in a scriptlet are being parsed as if it were markup
> > > rather than being treated as Java syntax less than symbol.
> > >
> > > For example the scriptlet
> > >
> > > <%
> > > for(int i=0; i<6; i++)
> > > out.println(i);
> > > %>
> > >
> > > works as expected in standard format jsp.
> > >
> > > The xml format scriplet shown below produces an exception
> > > org.apache.jasper.compiler.ParseException The content beginning "<6" is
> > > not legal markup
> > >
> > > <jsp:scriptlet>
> > >
> > > for(int i=0; i<6; i++)
> > > out.println(i);
> > >
> > > </jsp:scriptlet>
> > >
>
> The above is not valid XML, you cannot use < within a section of XML, unless
> it is within a CDATA section or is the start of a start tag.
>
> Bap.
sorry, "The above is not well-formed XML"
Re: More on JSP in XML format -- This, is a very excellent post!
Posted by Bap <li...@a1.org.uk>.
"Michael G. Anderson C.T.O" wrote:
> This, is a very excellent post!
>
> Anne and Bill Moore wrote:
>
> > Pierre Delisle wrote:
> > I have now found a bug with scriplets.
> > The < character in a scriptlet are being parsed as if it were markup
> > rather than being treated as Java syntax less than symbol.
> >
> > For example the scriptlet
> >
> > <%
> > for(int i=0; i<6; i++)
> > out.println(i);
> > %>
> >
> > works as expected in standard format jsp.
> >
> > The xml format scriplet shown below produces an exception
> > org.apache.jasper.compiler.ParseException The content beginning "<6" is
> > not legal markup
> >
> > <jsp:scriptlet>
> >
> > for(int i=0; i<6; i++)
> > out.println(i);
> >
> > </jsp:scriptlet>
> >
The above is not valid XML, you cannot use < within a section of XML, unless
it is within a CDATA section or is the start of a start tag.
Bap.
Re: More on JSP in XML format -- This, is a very excellent post!
Posted by "Michael G. Anderson C.T.O" <RI...@home.com>.
This, is a very excellent post!
Anne and Bill Moore wrote:
> Pierre Delisle wrote:
> >
> > <jsp:cdata> is currently not supported in tomcat-4.0.
> > You can either put the template data directly in the
> > jsp page, or you can simply use the standard XML tag
> > for CDATA: <![CDATA[... ]]>.
> >
> > Give it a try and let me know.
> >
> > Please report any JSP page in XML syntax that does not
> > work (except for the <jsp:cdata>). I'll make sure
> > the proper fixes are committed.
> >
> Pierre
> The CDATA approach works as you suggested, so I have continued my
> testing - I am using the Tomcat example jsps as my starting point - I
> aim to have an XML representation of each Tomcat example jsp.
>
> I have now found a bug with scriplets.
> The < character in a scriptlet are being parsed as if it were markup
> rather than being treated as Java syntax less than symbol.
>
> For example the scriptlet
>
> <%
> for(int i=0; i<6; i++)
> out.println(i);
> %>
>
> works as expected in standard format jsp.
>
> The xml format scriplet shown below produces an exception
> org.apache.jasper.compiler.ParseException The content beginning "<6" is
> not legal markup
>
> <jsp:scriptlet>
>
> for(int i=0; i<6; i++)
> out.println(i);
>
> </jsp:scriptlet>
>
> When you asked me to report bugs I was not sure if you mneant for me to
> enter them to bugrat - I created Bug Report #511 with synopsis
> "Error in parsing scriptlet when jsp is in xml format " to describe this
> problem.
>
> BTW Bugrat seemed to mangle the example scriptlet I entered in the
> problem description and seems to have lost the comment I put in the How
> to reproduce section.
>
> --
> Thanks and Regards
> Anne and Bill Moore
> nzmoore@bellsouth.net
> Remember: Life is too short to drink bad wine!!!
Re: More on JSP in XML format
Posted by Anne and Bill Moore <nz...@bellsouth.net>.
Pierre Delisle wrote:
>
> <jsp:cdata> is currently not supported in tomcat-4.0.
> You can either put the template data directly in the
> jsp page, or you can simply use the standard XML tag
> for CDATA: <![CDATA[... ]]>.
>
> Give it a try and let me know.
>
> Please report any JSP page in XML syntax that does not
> work (except for the <jsp:cdata>). I'll make sure
> the proper fixes are committed.
>
Pierre
The CDATA approach works as you suggested, so I have continued my
testing - I am using the Tomcat example jsps as my starting point - I
aim to have an XML representation of each Tomcat example jsp.
I have now found a bug with scriplets.
The < character in a scriptlet are being parsed as if it were markup
rather than being treated as Java syntax less than symbol.
For example the scriptlet
<%
for(int i=0; i<6; i++)
out.println(i);
%>
works as expected in standard format jsp.
The xml format scriplet shown below produces an exception
org.apache.jasper.compiler.ParseException The content beginning "<6" is
not legal markup
<jsp:scriptlet>
for(int i=0; i<6; i++)
out.println(i);
</jsp:scriptlet>
When you asked me to report bugs I was not sure if you mneant for me to
enter them to bugrat - I created Bug Report #511 with synopsis
"Error in parsing scriptlet when jsp is in xml format " to describe this
problem.
BTW Bugrat seemed to mangle the example scriptlet I entered in the
problem description and seems to have lost the comment I put in the How
to reproduce section.
--
Thanks and Regards
Anne and Bill Moore
nzmoore@bellsouth.net
Remember: Life is too short to drink bad wine!!!
Re: More on JSP in XML format
Posted by Pierre Delisle <pi...@sun.com>.
<jsp:cdata> is currently not supported in tomcat-4.0.
You can either put the template data directly in the
jsp page, or you can simply use the standard XML tag
for CDATA: <![CDATA[... ]]>.
Give it a try and let me know.
Please report any JSP page in XML syntax that does not
work (except for the <jsp:cdata>). I'll make sure
the proper fixes are committed.
-- Pierre
Anne and Bill Moore wrote:
>
> I anm still trying to get my head around JSP in XML format.
> Can anyone suggest further reading beyond the JSP Version 1.2 - Proposed
> Final Draft (PFD) spec or provide examples.
> When I try the examples like those from the spec using Tomcat Version
> 4.0 Milestone 4, I routinely get a java.lang.ClassCastException:
> org.apache.jasper.compiler.ParserXJspSaxHandler$Node.
> After some experimentation I was able to get very simple XML formatted
> JSP to work, but it seems that whenever the jsp contained a jsp:cdata
> element the class cast exception occurs.
> It may be that I have misunderstood the jsp:cdata element or is this a
> bug in Tomcat?
> --
> Thanks and Regards
> Anne and Bill Moore
> nzmoore@bellsouth.net
> Remember: Life is too short to drink bad wine!!!