How to get the XML translation to HTML dropdownlist with ajax? I send the parameter with GET method but the JSP file that generates the XML don't receive it.
var url = "responsexml.jsp";
url = url + "?projectCode=" + prj.options[prj.selectedIndex].value;
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET", url, true);
xmlhttp.send(null);
And then in responsexml.jsp I do like that:
<%
String projectcode = (String) request.getParameter("projectCode");
System.out.println("++++projectCode:=" + projectcode);
Session s = null;
Transaction tx;
try {
s = HibernateUtil.currentSession();
tx = s.beginTransaction();
Query query = s.createQuery("SELECT from Wa wa where wa.ProjectCode='" + projectcode + "'");
response.setContentType("text/xml");
PrintWriter output = response.getWriter();
output.write( "<?xml version=\"1.0\" encoding=\"utf-8\"?>");
//response.setHeader("Cache-Control", "no-cache");
if (projectcode != null) {
for (Iterator it = query.iterate(); it.hasNext();) {
if (it.hasNext()) {
Wa object = (Wa) it.next();
//out.print( "<item id=\"" + object.getIdWA() + "\" name=\"" + object.getWAName() + "\" />");
output.write("<wa>");
output.write( "<item id=\"" + object.getIdWA() + "\" name=\"" + object.getWAName() + "\" />");
output.write("</wa>");
}
}
}
} catch (HibernateException e) {
e.printStackTrace();
}
%>
</body>
</html>
With this code I don't have my XML file. I got this error:
The server did not understand the request, or the request was invalid. Erreur de traitement de la ressource http://www.w3.o...