I want to put in my
jsp document ( I just want to show off some capabilities of JSP, not necessarily the use of Beans or
Servlets, which I think would be better ) a looping construct to make a table of info based on a query...maybe the code will help more:
/******************Begin*Code*********************/
String proj=("<--SOMETHING IS WRONG-->");//a string to be return'd
try
{
/*************************************************BLOCK*OF*REAL*DB*WORK****************/
Class.forName(DRIVER); //-->generic DB-opening routine; constants come from EWOInfo.java
Connection con = DriverManager.getConnection(URL,USER,PASSWORD);
Statement st = con.createStatement();
String query = "SELECT projectCode, dateReceived, faceValue, approvedValue, status FROM tblEWOLog WHERE" +
"faceValue > " + faceValue;
ResultSet rs = st.executeQuery(query);
while(rs.next())
{%>
<TR>
<TD><% (rs.getString(1))%></td>
<td><% (rs.getString(2))%></td>
<td><% (rs.getString(3))%></td>
<td><% (rs.getString(4))%></td>
<td><% (rs.getString(5))%></td>
</tr>
<%
}
/***********************************************************************************/
st.close();//close the streams so no problems occur.
con.close();//See ^^^^ above, okay?
}//end of try statement
catch(SQLException sqle)
{
System.out.println("SQL Exception exists in JspGenerator Method.");
}
%>
</table>
/*************************/endcode/**********************/
Thanks,
Kevin