How to calculate the total of a sum in JSTL

Alex

How can I realise this with JSP and JSTL?

int total = 0;
for (Article article : list) {
    total += article.price;
}
Semih Eker

Use <c:set> to initialize the total variable, use <c:forEach> to iterate over list and use another <c:set> to add the iterated value to the total.

<c:set var="total" value="${0}"/>
<c:forEach var="article" items="${list}">
    <c:set var="total" value="${total + article.price}" />
</c:forEach>

See also Iterate over elements of List and Map using JSTL <c:forEach> tag.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

how to calculate total Sum in Excel

From Dev

how to calculate sum (Total) of DataTable Columns using C#

From Dev

How to calculate the total sum of items in array element using AngularJS

From Dev

How does CALCULATE, SUM, MAX and <= logically work for cumulative total?

From Dev

How to calculate the total sum of items in array element using AngularJS

From Dev

how to calculate sum (Total) of DataTable Columns using C#

From Dev

Dynamically calculate the total sum and vat

From Dev

How can i calculate total positive ,total negative price and sum using Node.js and Mongoose

From Dev

How to calculate % of total in MySQL

From Dev

How to calculate % of total in MySQL

From Dev

Javascript: how to calculate the total

From Dev

How to calculate vat using Checkbox after I get total_sum

From Dev

How to calculate of SUM of values?

From Dev

How to calculate "running total" in SQL

From Dev

How to calculate total price in php

From Dev

How to calculate the total distance traveled?

From Dev

How to Calculate Total Less Duplicates?

From Dev

How to calculate Last column total

From Dev

How to calculate a running total in view?

From Dev

How to calculate total price of order?

From Dev

How to Calculate Bill Total JS

From Dev

Using $sum to calculate the total value in a object, mongoose/mongodb

From Dev

Auto calculate total sum of a column with numeric data in datatable footer

From Dev

MySQL Sum positive and negative - calculate the exact total from money transactions

From Dev

Get column sum and use to calculate percent of total (mySQL)

From Dev

MySQL Sum positive and negative - calculate the exact total from money transactions

From Dev

How to calculate conditional cumulative sum

From Dev

How to Two table sum calculate

From Dev

Anylogic: how to calculate the cumulative sum?

Related Related

  1. 1

    how to calculate total Sum in Excel

  2. 2

    how to calculate sum (Total) of DataTable Columns using C#

  3. 3

    How to calculate the total sum of items in array element using AngularJS

  4. 4

    How does CALCULATE, SUM, MAX and <= logically work for cumulative total?

  5. 5

    How to calculate the total sum of items in array element using AngularJS

  6. 6

    how to calculate sum (Total) of DataTable Columns using C#

  7. 7

    Dynamically calculate the total sum and vat

  8. 8

    How can i calculate total positive ,total negative price and sum using Node.js and Mongoose

  9. 9

    How to calculate % of total in MySQL

  10. 10

    How to calculate % of total in MySQL

  11. 11

    Javascript: how to calculate the total

  12. 12

    How to calculate vat using Checkbox after I get total_sum

  13. 13

    How to calculate of SUM of values?

  14. 14

    How to calculate "running total" in SQL

  15. 15

    How to calculate total price in php

  16. 16

    How to calculate the total distance traveled?

  17. 17

    How to Calculate Total Less Duplicates?

  18. 18

    How to calculate Last column total

  19. 19

    How to calculate a running total in view?

  20. 20

    How to calculate total price of order?

  21. 21

    How to Calculate Bill Total JS

  22. 22

    Using $sum to calculate the total value in a object, mongoose/mongodb

  23. 23

    Auto calculate total sum of a column with numeric data in datatable footer

  24. 24

    MySQL Sum positive and negative - calculate the exact total from money transactions

  25. 25

    Get column sum and use to calculate percent of total (mySQL)

  26. 26

    MySQL Sum positive and negative - calculate the exact total from money transactions

  27. 27

    How to calculate conditional cumulative sum

  28. 28

    How to Two table sum calculate

  29. 29

    Anylogic: how to calculate the cumulative sum?

HotTag

Archive