Results 1 to 2 of 2
- 09-14-2012, 09:50 AM #1
Member
- Join Date
- Feb 2009
- Posts
- 25
- Rep Power
- 0
Displaying XML file using jsp declarations?
I have written code for generating XML file using jsp declarations.XML file is created properly but while displaying this data in browser it has given some problems.
in xml file it shows in following way.Java Code:<%! public String createXmlTree(Document doc,String name,String address,String contact,String email,String billduedate,String totalamountdue) throws Exception { ........................ ........................ StringWriter sw = new StringWriter(); StreamResult result = new StreamResult(sw); DOMSource source = new DOMSource(doc); transformer.transform(source, result); String xmlString = sw.toString(); return xmlString; /*File file = new File("d:/new.xml"); .......Generating for XML file BufferedWriter bw = new BufferedWriter(new FileWriter(file)); bw.write(xmlString); bw.flush(); bw.close();*/ }%> <% String name=pageContext.getAttribute("servicenumber").toString(); String address=pageContext.getAttribute("consumername").toString(); String contact=pageContext.getAttribute("billno").toString(); String email="ssss"; String billduedate="hai"; String totalamountdue=pageContext.getAttribute("totbillamount").toString(); try { System.out.println(name); DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = builderFactory.newDocumentBuilder(); Document doc = docBuilder.newDocument(); String xmlString = createXmlTree(doc,name,address,contact,email,billduedate,totalamountdue); out.println(xmlString ); out.println("<b>Xml File Created Successfully</b>"); } catch(Exception e) { System.out.println(e); } %>
<?xml version="1.0" encoding="UTF-8"?><XML>
<CONNECTIONNO>VN90301000622</CONNECTIONNO>
<CUSTOMERNAME>MANAGER TIBTAN</CUSTOMERNAME>
<BILLNO>7800555</BILLNO>
<BILLDATE>ssss</BILLDATE>
<BILLDUEDATE>hai</BILLDUEDATE>
<TOTALAMOUNTDUE>20151.00</TOTALAMOUNTDUE>
</XML>
this is required formate.
but whenever i want to display in browser it shows in following way..
VN90301000622 MANAGER TIBTAN 7800555 ssss hai 20151.00
how to display this in above formate..thanks for helpLast edited by srinivasmallabathula; 09-14-2012 at 10:57 AM.
- 09-14-2012, 10:29 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,458
- Rep Power
- 16
Re: Displaying XML file using jsp declarations?
First off, take that createXmlTree method out of there.
I'd have it called from a servlet myself, storing the result in the request, but either way it should not be there.
Then test it.
Because that is where your problem lies.
What exactly is the value of that returned String (seen in a console, not on a browser).Please do not ask for code as refusal often offends.
Similar Threads
-
Reg: Difference between declarations
By rummy in forum New To JavaReplies: 2Last Post: 01-27-2012, 05:20 PM -
In-loop declarations and performance question ...
By XmisterIS in forum New To JavaReplies: 1Last Post: 09-15-2010, 12:02 PM -
When I mix JSTL 1.0 and 1.1 taglib declarations, it causes a ParseException. Why?
By sangfroid in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 04-01-2010, 09:27 AM -
Valid declarations
By heat84 in forum New To JavaReplies: 1Last Post: 12-22-2007, 02:29 AM -
Help with valid declarations of a float
By baltimore in forum New To JavaReplies: 1Last Post: 07-31-2007, 10:28 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks