<%
String xmlReq = generateXML();
out.println(xmlReq);
%>
xmlReq is the XML string, and I want to print it out in browser, but it doesn't
print it out. But when I go to view|source, then I could see the XML.
any ideas? please help. thanks!!
-
Print a XML string to browser doesnt work in JSP (3 messages)
- Posted by: Matt Louden
- Posted on: October 12 2004 17:18 EDT
Threaded Messages (3)
- Print a XML string to browser doesnt work in JSP by Patrick Calahan on October 12 2004 18:57 EDT
- Print a XML string to browser doesnt work in JSP by Chris Nappin on October 15 2004 09:17 EDT
- Print a XML string to browser doesnt work in JSP by Chris Nappin on October 15 2004 09:20 EDT
-
Print a XML string to browser doesnt work in JSP[ Go to top ]
- Posted by: Patrick Calahan
- Posted on: October 12 2004 18:57 EDT
- in response to Matt Louden
The browser is trying to interpret the xml tags as HTML tags and, failing to do so, is ignoring them.
The simplest solution is to wrap the XML output in HTML <PRE> tags or in a CSS-styled block with the 'preformatted' attribute set (I forget offhand what the actual name of that attribute is). -
Print a XML string to browser doesnt work in JSP[ Go to top ]
- Posted by: Chris Nappin
- Posted on: October 15 2004 09:17 EDT
- in response to Matt Louden
Even wrapping the XML string in tags still won't work, a web browser will assume the tags are HTML and render or ignore them. You will need to replace each < and > character to < and > (see the very useful String.replaceAll() method) -
Print a XML string to browser doesnt work in JSP[ Go to top ]
- Posted by: Chris Nappin
- Posted on: October 15 2004 09:20 EDT
- in response to Chris Nappin
Sorry, my reply was automatically escaped. I hope this one works better!
tags won't work, the browser will still try to render tags within the "pre" block and ignore any that aren't HTML.
You need to replace < with &lt; and > with &gt;