What I am trying to do: A user hits the JSP on the web, the page hits an Oracle database and dynamically builds a sortable table.
Known problems: Besides the fact that it just isn�t working?
Passing the y value (a counter) to the JSP but even when I
Hard code in a value for y I get nothing.
Nothing displays.
I�ve extracted out most of the code and this should build a table within a &ITdiv> on another page but even when ran as a stand alone
I get errors. When I put it into the &ITdiv> All I see in the window where a table should be is my source code.
I�ve posted this in the JSP section and in Java section because I do not know where it should go.
As always, Thanks for the insights. I need some help as I have been struggling all week-end with this.
Side Note: all �less then� signs had to replaced with �&it�
And �onclick� had to replace with �onKlick� in order to post.
&IT%@ page import="java.sql.*" %>
&IT%@ page import="java.text.SimpleDateFormat" %>
&IT%@ include file="connectDB.jsp" %>
&ITHTML>
&ITBODY>
&ITSCRIPT FOR=window EVENT=onload LANGUAGE="javascript">
&IT% System.out.println("--------------------starting page--------------------");%>
&ITSCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">
&ITtable id="tblMISSION" width="100%">
&ITthead>
&ITtr bgcolor="lightyellow" style="font-size:10;font-weight:bold;font-family:arial" style="position:relative; top:expression(this.offsetParent.scrollTop -2);left: -1">
&ITth>&ITa href="#" title="Number" onklick="return sortTable(this)">#&IT/a>&IT/th>
&ITth>&ITa href="#" title="NAME" onklick="return sortTable(this)">NAME&IT/a>&IT/th>
&ITth>&ITa href="#" title="CITY" onklick="return sortTable(this)">CITY&IT/a>&IT/th>
&ITth>&ITa href="#" title="GENDER" onklick="return sortTable(this)">GENDER&IT/a>&IT/th>
&IT!--
&ITtd title="Number">#&IT/td>
&ITtd title="NAME">NAME&IT/td>
&ITtd title="CITY" >CITY&IT/td>
&ITtd title="GENDER" >GENDER&IT/td>
-->
&IT/tr>
&IT%
SimpleDateFormat formatter = new SimpleDateFormat("dd/MMM/yy");
String sql = "SELECT NUMBER, NAME, CITY, GENDER FROM MYTABLE ";
ResultSet rs = statement.executeQuery(sql);
String num="";
String name="";
String city="";
String gender="";
int counter=0;
System.out.println("--------------------calling while("+rs.next()+")--------------------");
while (rs.next())
{
//System.out.println("--------------------Hitting database--------------------");
num=rs.getString(1);
if(num == null){num = "";}
name=rs.getString(2);
if (name==null){name="";}
city=rs.getString(3);
if(city == null){city = "";}
gender=rs.getString(5);
if (gender==null){gender="";}
// add a step to convert from java to jsScript and put into an array
%>
&IT!-- Make a call to js to put all the data in a js array of data objects to be sorted. -->
&ITSCRIPT LANGUAGE="JavaScript">
SDBObject(num,name,city,gender, &IT% counter %>

;
&IT/SCRIPT>
&IT%
counter++;
%>
&IT!�I was just hard coding a table in here originally
&IT%
}
%>
&IT/thead>
&ITtbody id="sortData">&IT/tbody>
&IT/table>
&ITSCRIPT LANGUAGE="JavaScript">drawTable("sortDate");&IT/SCRIPT>
&IT%
statement.close();
connection.close();
%>
&IT/BODY>
&IT/HTML>
&ITSCRIPT LANGUAGE="JAVASCRIPT" TYPE="TEXT/JAVASCRIPT">
&IT!--
function drawTable(tbody) {
&IT%System.out.println("--------------------drawTable--------------------");%>
var tr, td;
tbody = document.getElementByID(tbody);
for(var k = 0; k &IT jsData.length; k++) {
tr = tbody.insertRow(tbody.row.length);
td = tr.insertCell(tr.cells.length);
td.setAttribute("align","center");
td.innerHTML = jsData[k].Num;
td = tr.insertCell(tr.cells.length);
td.innerHTML = jsData[k].NUM;
td = tr.insertCell(tr.cells.length);
td.innerHTML = jsData[k].NAME;
td = tr.insertCell(tr.cells.length);
td.innerHTML = jsData[k].CITY;
td = tr.insertCell(tr.cells.length);
td.innerHTML = jsData[k].GENDER;
td = tr.insertCell(tr.cells.length);
}
}
function sortTable(link) {
&IT%System.out.println("--------------------sortTable()--------------------");%>
switch(link.firstChild.nodeValue){
case "NUM":
js.Data.sort(sortByNumber);
break;
case "MISSION":
jsData.sort(sortByMission);
break;
}
drawTable("sortData")
return false;
}//end sortTable(link) function
function SDBObjects(name, city,gender, i){
&IT%System.out.println("--------------------SDBObjects()--------------------");%>
jsData[i] = {Num: i,NAME: name, CITY: city, GENDER: gender };
}
function sortByMission(a,b){
a = a.location.toLowerCase();
b = b.location.toLowerCase();
return((a&ITb) ? -1

(a>b) ? 1:0));
}
-->
&IT/SCRIPT>