java - JSP/XML : XML parse error - invalid XML -
i'm using apache tomcat 7.0.39, eclipse java ee juno, java jre 7 & java jdk 1.7.0_13.
i have problem xml, parse error :
error: invalid xml: <?xml version="1.0" encoding="utf-8"?> <data> <time>9</time> <instances>3</instances> </data>
my purpose information database , put them in google chart. there code :
<%@ page language="java" contenttype="text/html; charset=iso-8859-1" pageencoding="iso-8859-1"%> <%@ page import="java.sql.*" %> <%@ page import="java.sql.sqlexception" %> <%@ page import="java.sql.drivermanager" %> <% string iddata = request.getparameter("iddata"); class.forname("com.mysql.jdbc.driver").newinstance(); connection conn = drivermanager.getconnection("jdbc:mysql://localhost:3306/testcd","root",""); if(conn != null) { statement stmt = conn.createstatement(); stmt.execute("select id,number numberinstances id='"+ iddata +"'"); resultset rs = stmt.getresultset(); out.println("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>"); out.setcontenttype("text/xml"); out.println("<data>"); while(rs.next()) { out.println("<time>" + rs.getstring(1) + "</time>"); out.println("<instances>" + rs.getint(2) + "</instances>"); } out.println("</data>"); conn.close(); } %>
can me? have problem since yesterday , information got researches on google didn't help
if need more information, please ask me
finally, changed code use text response instead of xml response. jsp code data :
statement stmt = conn.createstatement(); stmt.execute("select number numberinstances id='"+ iddata +"'"); resultset rs = stmt.getresultset(); while(rs.next()) { out.println(rs.getint(1)); } conn.close();
and jsp code response :
$.ajax({ type: "get", url: "resources/jsp/getinstances.jsp", data: {iddata:(cptdata)}, datatype: "text", complete: function(text) { instance = text.responsetext*(1010); } });
Comments
Post a Comment