I wrote the following code:
<%
int accountNumber = Integer.parseInt(request.getParameter("accountNumber"));
int depositAmount = Integer.parseInt(request.getParameter("depositAmount"));
%>
<sql:query var='account' dataSource="jdbc/bank">
select * from account where AccountNumber=<%= accountNumber %>
</sql:query>
<c:forEach var="result" begin="0" items="${account.rows}">
<c:set var="balance" value="${ result.balance + depositAmount }" />
<c:out value="${ balance }" />
</c:forEach>
The problem is that for <c:set var="balance" />
it isn't actually adding the two values together.
I'm assuming that depositAmount isn't recognized? I'm not sure why.
Can someone please explain how I can use JSTL to get the request parameter (balance) and add it to the balance obtained in the query?
This is a homework assignment where I must use JSP.
Thank you