I'm running into an odd problem that I think has something to do with the
way scope works within the DBtags.  I need to create a variable to total the
cost for a list of items.  If I create a variable called total outside of
the DBtags, it doesn't seem to be in scope within  the loop that is
generating the rows of my table.  The same thing is happening with int a
that I am trying to use to alternate the bgcolor of my table.

Any suggestions?

--Mark

Here is the code:

   <%
     int a = 0;
     float total = 0; *********************************************
declaration
   %>

   <sql:resultSet id="rset2">
           <%

     total=total+rset2.getFloat("expected_cost"); *** why isn't it in scope
here?
     a = a + 1;
     if(a%2!=0) {%> 
       <tr bgcolor="#FFFFCC"> 
         <% }else {%>
       <tr bgcolor="#CCFFCC"><%}%>
         <td><sql:getColumn colName="description"/></td>
         <td><sql:getColumn colName="vendor"/></td>
         <td><sql:getColumn colName="expected_cost"/></td>
         <td><a href="delete_req_item.jsp?req_item_id=<sql:getColumn
colName="req_item_id"/>">delete </a></td>
       </tr>
     </sql:resultSet>
</sql:statement>
   
      <tr bgcolor="#CCCCFF">
      <td></td>
      <td align=RIGHT><b>Total:</b></td>*************** why isn't it in
scope here?
      <td><b><%=total%></b></td>
      <td></td>
   </tr>

Reply via email to