title: How to update value in <c:set> tag using EL inside a <c:foreach> tag
body: <p>I have <code>list</code> which contains some objects in it. The objects have an <code>hours</code> field.</p>
  
  <p>In the <code>&lt;c:foreach&gt;</code> I am iterating the list and fetching the objects.</p>
  
  <p>Now I want to sum up the <code>hours</code> field of all the iterated objects in a <code>totalHours</code> variable.</p>
  
  <p>My code:</p>
  
  <pre><code>&lt;c:forEach var="attendance" items="${list }" varStatus="rowCounter1"&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;c:out value="${rowCounter1.count}"&gt;&lt;/c:out&gt;&lt;/td&gt;
      &lt;td&gt;&lt;c:out value="${attendance.date }"&gt;&lt;/c:out&gt;&lt;/td&gt;
      &lt;td&gt;&lt;c:out value="${attendance.inTime }"&gt;&lt;/c:out&gt;&lt;/td&gt;
      &lt;td&gt;&lt;c:out value="${attendance.outTime }"&gt;&lt;/c:out&gt;&lt;/td&gt;
      &lt;td&gt;&lt;c:out value="${attendance.interval }"&gt;&lt;/c:out&gt;&lt;/td&gt;
  
      &lt;c:set var="totalHours" value="${attendance.Hours += attendance.Hours }"
             target="${attendance}"&lt;/c:set&gt;                                       
    &lt;/tr&gt;
  &lt;/c:forEach&gt;
  </code></pre>
  
  <p>I was trying this, but it gave me the following error:</p>
  
  <pre><code>javax.el.ELException: Failed to parse the expression [${attendance.Hours += attendance.Hours }
  </code></pre>