I am using JSTL to display the record in JSP that I search from database.
For example, these records returned from database are :
<tr>
<td class="leavehistory">2012-01-31 18:16:36.0</td><td class="leavehistory">Present</td>
</tr>
<tr>
<td class="leavehistory">2012-01-31 18:16:38.0</td><td class="leavehistory">Present</td>
</tr>
Here is my JSP :
<c:forEach items="${attendRecord}" var="attendRecord">
<tr>
<td class="leavehistory">${attendRecord.attendDt}</td><td class="leavehistory">${attendRecord.status}</td>
</tr>
</c:forEach>
Here is my Servlet :
ArrayList<Attendance> arrSub = new ArrayList<Attendance>();
while (rs.next()){
Attendance att = new Attendance();
att.setAttendDt(rs.getString(1));
att.setStatus(rs.getString(2));
att.setClsType(rs.getString(3));
att.setSubID(rs.getString(4));
arrSub.add(att);
}
request.getSession().setAttribute("attendRecord", arrSub);
Where I perform another search , the result will be like this :
<tr>
<td class="leavehistory">2012-01-31 18:16:36.0</td><td class="leavehistory">Present</td>
</tr>
<tr>
<td class="leavehistory">2012-01-31 18:16:38.0</td><td class="leavehistory">Present</td>
</tr>
<tr>
<td class="leavehistory">2012-01-31 18:16:36.0</td><td class="leavehistory">Late</td>
</tr>
<tr>
<td class="leavehistory">2012-01-31 18:16:38.0</td><td class="leavehistory">Late</td>
</tr>
Here is my code that used to call my servlet :
<script>
function reviewAtt(){
var f = document.review;
f.hdSearch.value = f.cardID.value +";"+document.getElementById("clsType").value+";"+document.getElementById("sub").value;
f.method = "POST";
f.target = "_self";
f.action = "../build/web/WEB-INF/classes/leave/searchAttendServlet";
f.submit();
}
</script>
Then I continue to perform another search action , the latest search result supposed to replace the old record and display the latest result. But It will not, the latest result will be added at the below of old record. I want to display the latest search result only. The old search result will be eliminated.
Is there any solution to solve this problem ?