I have the following code:
<%
for (int i = 0; i < rs.getFetchSize(); i++) {
System.out.print("test");
//blah
%>
<div id="Test<%= out.print(i) %>">
<div class="<%= oddOrEven(i)%>Header">
<div class="<%= oddOrEven(i)%>A">Test<% out.print(i);%></div>
<div class="<%= oddOrEven(i)%>B">
//Stuff here
Odd or Even simply responds with the word odd or even based on the number i passed to it, that should make my css style alternate between grey colors.
When I compile the page it works, but this part is totally omitted and doesn’t appear in the source. Can someone help me get this working?
The
ResultSet#getFetchSize()doesn’t return the amount of returned records as you seemed to expect. It just returns the configured fetch size. It may for instance just return0depending on the JDBC driver configuration and semantics.Just use
ResultSet#next()the usual way to move the cursor to the next row.That said, writing Java code in a JSP file is officially discouraged since a decade. I’d suggest to work on that part as well.