| Author |
displaying / using variables in loops
|
Atul Dusara
Greenhorn
Joined: May 03, 2003
Posts: 3
|
|
I have successfully managed to extract data from a database and can display it in a loop. The problem though is that I can't put an insert statement in the loop to write the variable to the database. If the query is outside the loop, it won't register. I have tried using request.getParameter , but that brings back 'null'. This is the code while (rs.next()) { String balance = rs.getString(9); float result = Float.parseFloat(balance); out.println(balance); int credit = Integer.parseInt(request.getParameter ("credits")); out.println(credit); float newbalance = result - credit; out.println(newbalance); } float test = Float.parseFloat(request.getParameter("newbalance")); out.println(test); // Brings back null
|
 |
Jessica Sant
Sheriff
Joined: Oct 17, 2001
Posts: 4313
|
|
and you're saying that when you have these lines inside of the while loop it works?? float test = Float.parseFloat(request.getParameter("newbalance")); out.println(test); // Brings back null how can a primitive float like test have a null value?? if the "newbalance" parameter is null, shouldn't you be getting a NullPointeException on the Float.parseFloat() line?? Are you sure you're looking for the right parameter name? what happens when you call request.getParameterNames() do you see the param there?
|
- Jess
Blog:KnitClimbJava | Twitter: jsant | Ravelry: wingedsheep
|
 |
 |
|
|
subject: displaying / using variables in loops
|
|
|