Hi all,
Firstly, an advanced thankyou for anyone willing to help.
I'm writing a JSP to display a table from a database, but the bean used passes back a vector (consisiting of more vectors) to the JSP and I have no idea how to parse through said vectors so I can output it to a table.
Here's my code so far:
The (segment of) bean:
public Vector<Vector<Object>> getAllStock()
throws SQLException
{
Vector<Object> row = null;
Vector<Vector<Object>> rows =
new Vector<Vector<Object>>();
connectToDb();
try
{
results = statement.executeQuery(
"SELECT * FROM Stock");
while (results.next())
{
row = new Vector<Object>();
row.add(results.getString(1));
row.add(results.getString(2));
row.add(results.getInt(3));
row.add(results.getInt(4));
row.add(results.getFloat(5));
rows.add(row);
}
}
catch (SQLException sqlEx)
{
//Error message
}
disconnectFromDb();
return rows;
}
And then the JSP:
<HTML>
<HEAD>
<TITLE>The tableName Database Table </TITLE>
</HEAD>
<BODY>
<H1>Displaying full stock list </H1>
<%
Vector resultset = stockacc.getAllStock();
%>
<TABLE BORDER="1">
<TR>
<TH>Stock Code</TH>
<TH>Stock Desc</TH>
<TH>Current Level</TH>
<TH>Reorder Level</TH>
<TH>Price</TH>
</TR>
<% while(resultset.next()){ %>
<TR>
<TD> <%= resultset.getString(1) %></td>
<TD> <%= resultset.getString(2) %></TD>
<TD> <%= resultset.getString(3) %></TD>
<TD> <%= resultset.getString(4) %></TD>
<TD> <%= resultset.getString(5) %></TD>
</TR>
<% } %>
</TABLE>
</BODY>
</HTML>
All help and advice greatly appreciated!