
Sample Ajax Code for getting values from another JSP

The below code is helpful to access another Action class
//In Main JSP file
var xmlHttpObj,xmlHttpObj1;
function getXmlHttpObject()
{
var oXmlHttp=null;
if(window.XMLHttpRequest) // For Non IE Browsers
{
oXmlHttp=new XMLHttpRequest();
}
else if(window.ActiveXObject)//For IE Browsers
{
oXmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
return oXmlHttp;
}
//Function to get all model for the selected vendor
function loadUserInfo(obj,racfId)
{
if(racfId!="")
{
xmlHttpObj=getXmlHttpObject();
if(xmlHttpObj==null)
{
alert("Browser doesn't Support HTTP Request");
return;
}
else
{
xmlHttpObj.open("POST",obj.contextPath.value+"/GetUserDetails.do",true);
xmlHttpObj.onreadystatechange=function(){ loadUserValue(obj,racfId); }
xmlHttpObj.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlHttpObj.send("racfId="+racfId);
}
}
}
function loadUserValue(obj,val)
{
if(xmlHttpObj.readyState==4 || xmlHttpObj.readyState=="complete")
{
var xmlDoc=xmlHttpObj.responseXML.getElementsByTagName('USER');
for(var eachRow=0;eachRow //==========JSP File================
<%@ page contentType="text/xml" %>
<USERS>
<USER>
<ONE><%= request.getAttribute("RACFID")%></ONE>
<TWO><%= request.getAttribute("FIRSTNAME")%></TWO>
<THREE><%= request.getAttribute("LASTNAME")%></THREE>
<FOUR><%= request.getAttribute("EMAILID")%></FOUR>
<FIVE><%= request.getAttribute("USERTYPE")%></FIVE>
<SIX><%= request.getAttribute("USERROLE")%></SIX>
<SEVEN><%= request.getAttribute("STATUS")%></SEVEN>
</USER>
</USERS>

Hi Friend,
Please visit the following link:
http://www.roseindia.net/jsp/comboSelect.shtml
Here you will get the useful example.
Thanks