tags:

views:

204

answers:

1

Hi,

I am new to the Java development. I need to populate XML fields in a JSP page.

I didn't do with JDBC actually i have written the Mysql wrapper in C

it executes the query and return the table value as XML.

Help me how to populate the XML fields in JSP?

how to read the XML file using JDBC ResultSet?

Will be much helpful

thanks

krishna

The XML File from C Wrapper

<?xml version="1.0" encoding="UTF-8"?>
<test>
<TableRow>
<name>
krishna
</name>
<Age>
30
</Age>
</TableRow>
<TableRow>
<name>
kumar
</name>
<Age>
40
</Age>
</TableRow>
<TableRow>
<name>
kumar
</name>
<Age>
40
</Age>
</TableRow>
</test>
+2  A: 

To handle XML as a java.sql.ResultSet you need to use a javax.sql.rowset.WebRowSet.

Chances are the XML your C wrapper is generating isn't in a format that javax.sql.rowset.WebRowSet will understand so you'll have to do a transformation using XSLT.

With regards to rendering fields in a JSP, use the JSTL c:out tag. If you want you JSP itself to be XML you need to set the content-type to text/html using the following page directive:

<%@page contentType="text/xml" %>
Nick Holt
thanks nickwill update you if i get any errors and exceptions
krishnakumar