title: How to change Map value dynamically in JSTL
body: <p>One of our application built using Spring MVC + JSP.
  Please refer below JSP.</p>
  
  <pre><code>&lt;%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%&gt;
  &lt;%@ page import="java.util.ArrayList"%&gt;
  &lt;%@ page import="java.util.HashMap"%&gt;
  &lt;%
      ArrayList&lt;HashMap&lt;String, String&gt;&gt; listOfMap = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
  
      HashMap&lt;String, String&gt; map;
  
      for (int i = 0; i &lt; 3; i++) {
          map = new HashMap&lt;String, String&gt;();
  
          map.put("key1", "value1" + i);
          map.put("key2", "value2" + i);
  
          listOfMap.add(map);
      }
  
      request.setAttribute("listOfMap", listOfMap);
  %&gt;
  &lt;html&gt;
  &lt;body&gt;
      &lt;c:forEach items="${listOfMap}" var="maps"&gt;
          &lt;c:forEach items="${maps}" var="mapItem"&gt;
                  ${mapItem.key} ${mapItem.value} &lt;br /&gt;
          &lt;/c:forEach&gt;
      &lt;/c:forEach&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>As you can see in this jsp that i am trying to iterate map and display key and value on page.</p>
  
  <p>But what should be done in case if i want to change the value of <code>mapItem.key</code> and <code>mapItem.value</code> while iterating inside the loop.</p>
  
  <p>So it would like below.</p>
  
  <pre><code>&lt;c:forEach items="${listOfMap}" var="maps"&gt;
      &lt;c:forEach items="${maps}" var="mapItem"&gt;
              &lt;!--Basically i would write a code (in scriplet) to prevent cross site scripting here --&gt;
              ${mapItem.key} ${mapItem.value} &lt;br /&gt;
      &lt;/c:forEach&gt;
  &lt;/c:forEach&gt;
  </code></pre>