This is from jsp spec Why <![CDATA is being used ??? cant i just say <jsp:text><title>asdasd<title></jsp:text> XML VIEW OF JSP PAGE: <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:eg="http://java.apache.org/tomcat/examples-taglib" xmlns:test="urn:jsptld:/tomcat/taglib" xmlns:temp="urn:jsptld:/WEB-INF/tlds/my.tld" version="1.2"> <jsp:text><![CDATA[<html> <title>positiveTagLig</title> <body> ]]></jsp:text> <eg:test toBrowser="true" att1="Working> <jsp:text>Positive test taglib directive</jsp:text> </eg:test> <jsp:text><![CDATA[ </body> </html> ]]></jsp:text> </jsp:root>
Gaurav Chikara
Ranch Hand
Joined: Jun 09, 2000
Posts: 410
posted
0
hi can u tell me how to use xml syntax with jsp for example <%="hello"%> <% int i=0; %> <% int i=0;%> <% for(i=0;i<8;i++) {%> out.println(<%=i%> ; <% } %> <%="hello2"%> gives the output hello int i=0; out.println(0); out.println(1); out.println(2); out.println(3); out.println(4); out.println(5); out.println(6); out.println(7); hello2 but if i try with xml syntax <jsp:expression> "hello" </jsp:expression> <jsp:scriptlet> int i=0; </jsp:scriptlet> <jsp:scriptlet> for(i=0;i<8;i++) {</jsp:scriptlet> out.println(<jsp:expression>i</jsp:expression> ; <jsp:scriptlet> } </jsp:scriptlet> it gives weird output "hello" int i=0; for(i=0;i<8;i++) { out.println(i); } how u r doing it with xml?
SCJP,SCWCD,SCBCD<br />If Opportunity doesn't knock then build the door
Peter den Haan
author
Ranch Hand
Joined: Apr 20, 2000
Posts: 3252
posted
0
Originally posted by shan java: Why <![CDATA is being used ???
Because the XML contained in it isn't well-formed -- it contains XML opening tags "html" and "body" without corresponding closing tags. By using a CDATA section you tell the HTML parser to treat the content as flat character data, not as XML.
cant i just say <jsp:text><title>asdasd<title></jsp:text>
Yes you can, as this is well-formed XML. If you are unsure about the concept of well-formedness I'd recommend you read a good XML tutorial; you won't properly understand JSP XML format unless you understand XML. - Peter [ April 11, 2002: Message edited by: Peter den Haan ]