ciao a tutti

ho questo problema:invio dati ajax ad una servlet, questa mi restituisce un xml, dopodichè devo stampare il contenuto

lato client ho questa funzione:

function getXMLHttp() {
var xmlhttp = null;
if (window.ActiveXObject) {
if (navigator.userAgent.toLowerCase().indexOf("msie 5") != -1) {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} else {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
}

if (!xmlhttp && typeof(XMLHttpRequest) != 'undefined') {
xmlhttp = new XMLHttpRequest()

}
return xmlhttp
}


function validate(){
var q = document.getElementById("query");

//if (window.ActiveXObject) {

//var xmlDoc=null;
// xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
//xmlDoc.async="false";
//xmlDoc.load("q");
//}

objHTTP = getXMLHttp();
objHTTP.open("post", "Matricola2", true);
objHTTP.onreadystatechange = function() {elaboraRisposta()}
objHTTP.send("q=" + encodeURIComponent(q.value));

function elaboraRisposta() {
if (objHTTP.readyState == 4) {






alert( objHTTP.responseXML.getElementsByTagName("cquery")[0].getAttribute("q"));

}
}

}

questa è la servlet:

public class Matricola2 extends HttpServlet {

public void init(ServletConfig config) throws ServletException {
super.init(config);
}

public void doGet(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
this.doGetPost(request, response);
}

public void doPost(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
this.doGetPost(request, response);
}

public void doGetPost(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
request.setCharacterEncoding("UTF-8");
response.setContentType("text/xml");
response.setHeader("Cache-Control", "no-cache");


String pippo=request.getParameter("q");

String risposta= "<root><cquery q=\"" + pippo + "\"></cquery></root>";



response.getWriter().write(risposta);



}
}

l'alert mi restituisce sempre null, come se i dati non venissero inviati e ricevuti.

qualcuno sa aiutarmi??