Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to acess request attribute in java script

Status
Not open for further replies.

meenu24

Programmer
May 5, 2006
37
US
Hi

I am using ajax to submit the request and then getting the response back to display contents of a div.

this is my code.

function showDiv(setname,url) {
if (window.XMLHttpRequest){ // if Mozilla, Safari etc

page_request = new XMLHttpRequest();
}
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e1){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e1){}
}
}
else
return false;
page_request.onreadystatechange = function(){ callback(page_request)};
page_request.open('GET',url, true);
page_request.send(null);
}

function callback(page_request)
{
if (page_request.readyState == 4) {
if (page_request.status == 200) {
document.getElementById("setaffiiates").innerHTML = page_request.responseText;
document.getElementById("setaffiiates").style.display = "block";
}
}
}


my div code is

<div id="setaffiiates" style="display:none;position: absolute; padding:2px; width: 225px; z-index: 500;">
<% NetworkSet[] netSets = (NetworkSet[])request.getAttribute("netSets"); %>
<table>
<tr>
<td>
<%=netSets[0].network%>
</td>
</tr>
</table>
</div>


Pl excuse if I have mixed the JSP code there. But I have to show all the code for clarity. Now the issue when i get the reponse I see the whole html page again with the div portion again. So it is like the page and again page with div code.
What should I do if I want to get the div area and not the whole page once more again

thanks
Meena

 
Thanks Dan, you mean forming response in XML format from the servlet and then returning will be best solution.
I use struts, this is my servlet code.
Code:
request.setAttribute("setname", setName);
return mapping.findForward("setaffiliates");
I guess, I have to form some XML and then forward the request object.
I will try it.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top