How to multiply values from different coloumn in jsp servlet

3.1k Views Asked by At

I want to multiply resultSet.getInt("price") with resultSet.getInt("quantity")

And give the result in my html How can i do it? P.s im a beginner

2

There are 2 best solutions below

1
On BEST ANSWER

Try below....

<% int price = resultSet.getInt("price");
   int qty = resultSet.getInt("quqntity");
   int value = price * qty;
%>

Result Value (price * quantity)  = <% = value %>

Please let me know if you have any further queries

1
On

I hope it will help...!

 <%
int grandtotal=0;
while(resultSet.next()){
int price = resultSet.getInt("price");  
int quantity = resultSet.getInt("quqntity");  
grandtotal =grandtotal+(price * quantity); 
}

%> Result=<%=grandtotal%>.