Mahfuzul islam wrote:As per your tips i have checked the "View source" and found there is the complete XML file. I think in jsp out.println is only showing the value ignoring the xml body. Right?
No, that's not right. It can't be right because you yourself checked and found the whole XML file being displayed by the browser. And what you see in the browser's source is what the JSP outputs, nothing more or less. So it's like I said, the browser is handling your XML in a way you don't like.
So what you need to do is to escape the XML, so the browser treats it as text instead of markup.
Which brings us to another important point.
Java code like this has no place in a JSP. It should be put in a
servlet, or some other Java class, and then the servlet should put the desired data into request scope before forwarding to the JSP whose job is only to generate the output. And in that JSP
you should use the EL (expression language) to handle data forwarded in request scope from the servlet. As it happens the <c:out> element will automatically escape XML, which is exactly what you want.
Your alternative would be to write your own code to process that
string and escape the XML it contains. But why would you want to do that when the code you should be using will do it for you automatically?