[jdom-interest] XMLOutputter w/ JspWriter

Jay Xu jxu at san.rr.com
Thu Apr 11 18:01:46 PDT 2002


I am constructing a JSP and in that page, one part of table will be the
output of a transformed XML data (with XSL). Here is the part of JSP,

>
>     <TABLE cellspacing="0" cellpadding="4" width="100%"
> bgcolor="#eeeeee" border="0">
>     <TBODY>
>     <TR>
>     <TD align="right">
> <%
> out.println("Getting Alerts<br>");
> //		PrintWriter lout = response.getWriter();
> 		VMPIDataConnector vmpi = new VMPIDataConnector();
> 		vmpi.merge();
> 		try {
> 			vmpi.transform();
> 		} catch (JDOMException e) {
> 			e.printStackTrace();
> 		}
>
> 	vmpi.printJSPResult(out);
> %>
>     </TD>
>     <TD></TD>
>     </TR>
>     </TBODY>
>     </TABLE>
>

I am passing JspWriter out to vmpi.printJSPResult and expecting the
XMLOutputter will direct data to JspWriter. Here is the part of Java code,

> 	public void printJSPResult(JspWriter out) {
> 		try {
> 			XMLOutputter fmt = new XMLOutputter();
> 			fmt.setOmitDeclaration(true);
> 			fmt.output(rsltdoc, out);
> 		} catch ( Exception e) {
> 			e.printStackTrace();
> 		}
> 	}
>
>

To my surprise, I DID receive the XMLOutputter data, but this output is
somehow attached to the end of JSP output, not in the place which in the
middle of JSP output I was expecting. Here is part of resulted HTML,

> ......
> </BODY>
> </HTML>
> Getting Alerts<br>
> <table xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
> cellspacing="0" cellpadding="1" width="100%" border="0"><tr
> id="TableTextHead"><td width="100 NOWRAP"> Location </td><td
> width="90 NOWRAP"> Date </td><td width="60 NOWRAP"> Pat Type
>
> .....
>

I am new to Java and JDOM. My background has always been in C/C++. But Java
is quite exciting to me right now, especially with JDOM and XML.

Any suggestions will be greatly appreciated. Thank you in advance.


Jay Xu

Phone:		+1 858 676 0318 (W) 	+1 858 676 0278 (H)
Mobile:		+1 858 335 1817
Email:		jxu at san.rr.com                   jay.xu at smed.com
Home Page:	http://home.san.rr.com/kathyandjay/




More information about the jdom-interest mailing list