samarinder 0 Newbie Poster

I am displaying the results by iterating the list in div tag say "results" in my case.For refining of search i am using ajax call. But when i am getting response back from this below snippet

document.getElementById("results").innerHTML=xmlHttp.responseText;

. Its showing me content of JSP in which i am refining my list.

I am copying down the code for better understanding

Result.jsp

<div id ="results" style="position: absolute; left: 10px;  width: 540px; z-index: 24;"><%
                   
out.print("category_id is " + session.getAttribute("categoryId"));
if(session.getAttribute("list_full_detail_real_estate")!=null){
List<RealEstateVo> list_full_detail_real_estate = (List)session.getAttribute("list_full_detail_real_estate");

List<RealEstateVo> list_full_detail_real_estate1 = (List)session.getAttribute("list_full_detail_real_estate");

int size =  list_full_detail_real_estate.size();
%><%
for(int j = 0;j<size;j++){
%>

		<!-- Start of News Box 4 -->

			<div class="newsbox">

				<div class="newsbox_header">

				<!-- News Title -->
				Summary :&nbsp;<a href="detailsummary.do?summary_id=<%=list_full_detail_real_estate.get(j).getSummaryid()%>" style='color:#009900; font-size:18px;' title = ''><%=list_full_detail_real_estate.get(j).getSummary()%><br></a>
				
			
				<!-- News Date -->
				<strong>Date : <%=list_full_detail_real_estate.get(j).getDate()%></strong>

				<div class="clearthis">&nbsp;</div>
				</div>


				<div class="newsbox_content">
<%String swapvalue = list_full_detail_real_estate.get(j).getSwap();
			
			if(swapvalue!=null){ %><b>This item is marked for SWAP </b><br><%}%>
				<!-- News Text -->
							<img alt="VERY NICE FLAT AT CHOICE GARDENS,TOC-H ROAD" src="http://img.quikr.com/k/20100623/240557137-1277264013_sq.JPG" style="top: 207px; height: 47px; left: 500px; width: 110px;">
					<br><b>Category: </b><%=list_full_detail_real_estate.get(j).getCategory() %>
					<br><b>Sub Category: </b><%=list_full_detail_real_estate.get(j).getSubcategory()%>
					
					<br><b>Type of property: </b><%=list_full_detail_real_estate.get(j).getType() %>
					<br><b>Price: </b><%=list_full_detail_real_estate.get(j).getBudget() %>
					<br><b>Area of property: </b><%=list_full_detail_real_estate.get(j).getArea() %>
					<br><b>No. of rooms: </b><%=list_full_detail_real_estate.get(j).getNoofrooms() %>
					<br><b>Ownership type: </b><%=list_full_detail_real_estate.get(j).getOwnership() %>
		
		
			<br><b>Name: </b><%=list_full_detail_real_estate.get(j).getUsername() %>
			<br><b>City : </b><%= list_full_detail_real_estate.get(j).getLocation()%><br>
			<b>Sub Location : </b><%=list_full_detail_real_estate.get(j).getSublocation()%>
				<p>
			Description : <%=list_full_detail_real_estate.get(j).getDescription()%> 				</p>

				<br />

				</div>

refineresult.js

var xmlHttp

function frombudget(str)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var frombudget = document.getElementById("frombudgetreal").value;
var tobudget = document.getElementById("tobudgetreal").value;

//var category_id = document.getElementById("category_id");
    
    // get selected continent from dropdown list
  //  var selectedContinent = category_id.options[category_id.selectedIndex].value;
    var param = "frombudget=" + frombudget +"&tobudget="+tobudget; 
    // url of page that will send xml data back to client browser
    var requestUrl;
    // use the following line if using asp
    requestUrl = "refinerealestateresults.jsp?" + param
   
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",requestUrl,true);
xmlHttp.send(null);
}

function stateChanged() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById("results").innerHTML=xmlHttp.responseText;
}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

refinerealestateresults.jsp - This is the jsp in which i am refining my result list based on certain parameters and again setting it in session. Now ideally i want to get this list back from session in result div in result.jsp(main result page). But i am getting the response of this refinerealestateresults.jsp in div tag of result.jsp. I understand i m getting that because in am adding the response of in div tag by this. document.getElementById("results").innerHTML=xmlHttp.responseText;

But i don't want to replace the innerHTML of my results div. I just want to my div to get refresh with new refined list.

refinerealestateresults.jsp
<%@ page language="java" import="java.sql.*,com.project.db.*,java.util.*,com.project.web.*,com.project.vo.*" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<script src="refinefilter.js"></script>
</head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Ajax Call Test</title>
<body>
<%

	try
{
	String frombudget=request.getParameter("frombudget");
	String tobudget=request.getParameter("tobudget");

	out.println("frombudget" + frombudget);
	out.println("tobudget" + tobudget);

	List<RealEstateVo> list_full_detail_real_estate = (List)session.getAttribute("list_full_detail_real_estate");

    Iterator iterator = list_full_detail_real_estate.iterator();
    
    
    iterator.next();    	
    iterator.next();    	
    iterator.remove();    	

    session.setAttribute("new_list_full_detail_real_estate",list_full_detail_real_estate);

	
}
catch(Exception e)
{
	out.println("The General Exception: "+e);
} %>


<br>

</body>
</html>

The one solution to my above problem is that i will create same table structure in refinerealestateresults.jsp also so that when i will get response, it will visible to end user with no difference.But that i don't want to do because i need further do pagination and stuff like and this may cause problem there.

I hope you guys understand my problem. Please try to help me out. Thanks in advance.

Sam