In my servlet I am creating a multi-dimensional array that I am trying to use in my JSP to check something. Here it is my setup in the servlet:
List<List<String>> tableList = new ArrayList<List<String>>();
for (String selectedItem : selectedItems)
{
String schedcombo = selectedItem;
Integer modifyScheduleNum = Integer.parseInt(schedcombo.substring(0,5));
Integer modifyContractYear = Integer.parseInt(schedcombo.substring(5,9));
String newStatus = request.getParameter("ModifyStatus_" + selectedItem);
String newStatusDate = request.getParameter("ModifyStatusDate_" + selectedItem) ;
System.out.println("Schedule Number being processed is " + modifyScheduleNum +
" with contract year of " + modifyContractYear +
" with modified status of " + newStatus +
" with modified Status Date of " + newStatusDate);
List<String> rowpull = new ArrayList<String>();
rowpull.add(schedcombo.substring(0,5));
rowpull.add(schedcombo.substring(5,9)) ;
rowpull.add(newStatus);
rowpull.add(newStatusDate);
tableList.add(rowpull);
request.setAttribute("preeditList",tableList) ;
}
I did a print of the array processed and it looks like this:
The arraylist of table used that is added to table is : [[43080, 2016, RP, 2016-02-04]]
On the JSP I am doing a loop of my table and inside the loop I check the ArrayList to see if there are processesd in servlet. Here is my JSP code:
for(var i=0; i<updateformID.selectedSched.length; i++)
{
var checkSchedule = document.getElementById("checkedTable").rows[i + 1].cells[1].innerHTML;
var checkYear = document.getElementById("checkedTable").rows[i + 1].cells[2].innerHTML;
alert("CheckSchedule being pulled outside the ForEach is " + checkSchedule) ;
<c:remove var="cksched"/>
<c:forEach items="${preeditList}" var="editTable">
<c:set var="cksched" value="${editTable[0]}" scope="request" />
alert("schedule number Inside the foreach loop " + <c:out value="${cksched}"/>) ;
<c:set var="ckeftyear" value="${editTable[1]}" scope="request" />
alert("eft contract year Inside the foreach loop " + <c:out value="${ckeftyear}"/>) ;
<c:set var="ckstatus" value="${editTable[2]}" scope="request" />
alert("sched status Inside the foreach loop " + <c:out value="${ckstatus}"/>) ;
<c:set var="ckstatusDate" value="${editTable[3]}" scope="request" />
<c:if test="${cksched == checkSchedule}">
<c:set var="checkfound" value="YES" scope="request"/>
</c:if>
</c:forEach>
alert ("The checkfound variable after the foreach is " +
<%= request.getAttribute("checkfound") %> ) ;
}
In doing a debug of the screen, when I get to the alert message on the ckstatus field it fails saying that 'RP' is undefined. The first two are showing up correctly.
Is my problem that when I add to the rowpull array that I am not putting it in as a string correctly or a syntax in the alert or the actual processing that is just wrong?
Thanks again