Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I don't know whether can or not to do a code for make a calculation, the data get from SQL and code for calculation create at JSP file.

I hope anyone can tell me the solution for this problem, Thank You!

What I have tried:

From this code, the totalmealAlw, totalmealAlwS and totalmealAlwP I want to do the add operation:
<tr>
    <td>Total Meal ALW</td>
    <td><%=rs.getString("totalmealAlw") %></td>
    <td>Total Meal ALW</td>
    <td><%=rs.getString("totalmealAlwS") %></td>
    <td>Total Meal ALW</td>
    <td><%=rs.getString("totalmealAlwP") %></td>
</tr>


I want to make a calculation, but I don't know the right code to type:

double meal = <%=rs.getString("totalmealAlw") %> + <%=rs.getString("totalmealAlwS") %>; 
out.println(meal);
Posted
Updated 25-May-22 20:54pm
v2
Comments
Richard Deeming 26-May-22 3:43am    
If your values are numbers, why are you storing them as strings? Adding two strings together won't give you the result you expect - for example, "1" + "1" == "11".
aufa 2022 31-May-22 22:53pm    
ouhh okay, so I've to write rs.getDouble();... Thank you in advance...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900