pass xml to jsp/java

Hello All,

I have the JS function which i connect to a .dll's and get back XML String. I want to pass this xml to my java/jsp. I am guessing that i can do it with AJAX.

here is what i am trying to do:

<script language="javascript" type="text/javascript">

var xmlHttp;

function createXMLHttpRequest(){

if (window.ActiveXObject){

xmlHttp =new ActiveXObject("Microsoft.XMLHTTP");

}

elseif (window.XMLHttpRequest){

xmlHttp =new XMLHttpRequest();

}

}

function doRequestUsingPOST(){

createXMLHttpRequest();

var url ="<?xml version='1.0' encoding='UTF-8'?><navistor><data request='test'><rows><row store='350' storeident='2560' division='001' state='MA' city='woburn' phone='978-547-9000'/><row store='350' storeident='2560' division='001' state='MA' city='woburn' phone='978-547-9000'/></rows></data></navistor>";

var QueryURL ="test="+url;

alert(QueryURL);

xmlHttp.onreadystatechange = handleStateChange;

xmlHttp.open("POST", url,true);

xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

xmlHttp.send(url);

}

function handleStateChange(){

alert('Ready status:'+xmlHttp.readyState);

alert('Status:'+xmlHttp.status);

if(xmlHttp.readyState == 4){

if(xmlHttp.status == 200){

alert('handleStateChange:');

parseResults(xmlHttp.responseText);

}

}

}

function parseResults(output){

alert('parseResults o/p:'+output);

var xmloutput = output;

var objXML =new ActiveXObject("MSXML.DOMDocument");

objXML.async =false;

objXML.loadXML(output);

alert(output);

var rows = objXML.selectNodes("//row");

alert(rows.length);

}

</script>

The problem here is:. I am not able to get into (xmlHttp.status == 200) it is failing here and when i remove this 'if' stmt and try i am getting an alert stmt with all junk. Please help me in solving this issue.

I am open to any ways to pass xml from javascript to java/jsp . It is not like I will have to use only this method. If i am wrong please suggest me some suitable method.

Thank you...

[3405 byte] By [shravanoua] at [2007-11-27 10:43:35]
# 1

In your doRequestUsingPOST(), url must be an action.

xmlHttp.send(url);

not url, send the query string.

skp71a at 2007-7-28 20:01:16 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...