Print a XML string to browser doesn't work in JSP  
Author Message
jrefactors





PostPosted: 2004-10-13 5:17:00 Top

java-programmer, Print a XML string to browser doesn't work in JSP 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.

<%
String xmlReq = generateXML();
out.println(xmlReq);
%>

any ideas? please help. thanks!!
 
Brusque





PostPosted: 2004-10-13 6:41:00 Top

java-programmer >> Print a XML string to browser doesn't work in JSP
"Matt" <email***@***.com> wrote in message
news:email***@***.com...
> 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.
>
> <%
> String xmlReq = generateXML();
> out.println(xmlReq);
> %>
>
> any ideas? please help. thanks!!

Because you're not escaping the XML characters and the browser is trying to
render them/ignore them. You need to convert characters like < > & to >
< & etc. if you want the browser to display it instead of interpret
it.