Forums Register Login

Problem with XML syntax

+Pie Number of slices to send: Send
I am experimenting with the XML syntax alternative in JSPs. in the fragment below, the compiler is tripping up on the "<" in the for loop and concluding that my <jsp:scriplet> element doesn't have a valid end tag. I tried replacing "<" with "<" and my intuition was right that that simply replaces a parsing error with a syntax error. How do I escape the "<" or otherwise do something to eliminate this problem? (I prefer a solution that doesn't involve using the Expression Language.)

<CODE>
...
<TABLE BORDER=1>
<jsp:scriptlet>
Iterator entries = request.getParameterMap().entrySet().iterator();
while(entries.hasNext()) {
Map.Entry entry = (Map.Entry) entries.next();
String key = (String) entry.getKey();
String[] values = (String[]) entry.getValue();
for(int i = 0; i < values.length; i++) {
</jsp:scriptlet>
<TR><TD><jsp:expression> key </jsp:expression>
<TD><jsp:expression> values[i] </jsp:expression>
<jsp:scriptlet>
}
}
</jsp:scriptlet>
</TABLE>
...
</CODE>
+Pie Number of slices to send: Send
 

I am experimenting with the XML syntax alternative in JSPs.



Why? Are you auto-generating this code? The XML syntax is intended as an intermediate format for JSP containers to use internally, and for JSPs that are auto-generated by code that wish to create an in-memory DOM of the page and then serialize it.

Hand-coding the XML syntax is not really an intended usage.
+Pie Number of slices to send: Send
I think you should use "<" in place of "<" in the for loop.... "<" is the way comparison is done in XML....
+Pie Number of slices to send: Send
 

Originally posted by Sushma Sharma:
I think you should use "<" in place of "<" in the for loop.... "<" is the way comparison is done in XML....



I'm assuming there is a typo in that statement somewhere
+Pie Number of slices to send: Send
no, actually I typed "& lt ;" (ampersand lt semicolon) without spaces, and since it is XML enabled, so it converted that into <...

+Pie Number of slices to send: Send
&lt;

Ta-dah!

(&amp;lt;)
[ July 11, 2005: Message edited by: Yuriy Zilbergleyt ]
+Pie Number of slices to send: Send
Bear B. asks why I am trying to do this. Answer: Just as part of teaching myself Servlets & JSPs. I understand your point and might never use the XML syntax in practice, though the two books I am using -- Marty Hall and Larry Brown's Core Servlets and JavaServer Pages, Second Edition (see chapter 11 on XML syntax) and The J2EE Tutorial, Second Edition (see chapter 13 on JavaServer Pages Documents) -- don't seem to find anything wrong with using it even in a non-auto-generated development environment. The Tutorial even suggests some advantages.

Sushma: In my original post I attempted to say that I had already tried the character entity 'ambersand lt ;' (which, as in your original reply, got translated into '<'!). The point was that when I do that, I get a syntax error (i.e., the XML parser now recognizes the validity of my <jsp:scriptlet>...</jsp:scriptlet> start and end tags, but the compiler compiling the Java code between these tags chokes on the character entity, which of course is not valid Java syntax. So my problem remains unsolved. (Going back to Bear's point, I wonder what an auto-generator would do?)
+Pie Number of slices to send: Send
 

I wonder what an auto-generator would do?



It would create full-compliant XML. That means using CDATA sequences and entities where appropriate.

Which is why I see no advantage to the XML syntax for hand-coded pages. Once you've added all the necessary markup to keep the page legal, it's an unreadable (at least by humans) mass of markup goo that obfuscates the actual content of the page.

YMMV.
+Pie Number of slices to send: Send
 

Originally posted by Bear Bibeault:


It would create full-compliant XML. That means using CDATA sequences and entities where appropriate.

Which is why I see no advantage to the XML syntax for hand-coded pages. Once you've added all the necessary markup to keep the page legal, it's an unreadable (at least by humans) mass of markup goo that obfuscates the actual content of the page.

YMMV.



Point taken! Even my simple page is indeed an unreadable mass of markup goo. But I can still be curious ...
+Pie Number of slices to send: Send
 

But I can still be curious



Curious is good! I guess I just feel that there are more important (and practical) concepts that you could be curious about!
Arch enemy? I mean, I don't like you, but I don't think you qualify as "arch enemy". Here, try this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1101 times.
Similar Threads
jsp written in xml
How to write jsp with xml syntax
tags:panel not working in a particular situation
XML VIEW OF JSP PAGE:
howto set primary key column with color
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 02:31:28.