title: java.util.ConcurrentModificationException when iterating over a hashmap with struts iterator
body: <p>I am trying to use a hashmap to populate textfields in a jsp and bring back the modified values in the action class through the same hashmap i used to populate. In spite of many different approaches, i am failing to do so. I tried sending back an object list but i failed in that too(see <a href="https://stackoverflow.com/questions/15338286/editing-arraylist-of-objects-with-struts-2-form-tag/15343980?noredirect=1">this thread</a>). Its not necessary that i use the following approach, but <strong>i just want to take a modified list back to action class through struts tags</strong>. Please help me in this i already wasted a lot of time in this.</p>
  
  <p><strong>Action class code</strong></p>
  
  <pre><code>private HashMap&lt;String,Integer&gt; coursesMarks;
  //getters and setters
  
  public String editCoursePage() {
          this.student = studentService.getStudent(rollNo);
          this.courseList = courseService.getStudentCourses(rollNo);
          coursesMarks = new HashMap&lt;String, Integer&gt;();
  
          for(Course c: courseList) {
              coursesMarks.put(c.getCourse(), c.getMarks());
          }
          return ActionSupport.SUCCESS;
      }
  
      public String editCourseAction() {
  
          System.out.print("inside of student action "
                  + coursesMarks.size() + "\n\n\n");
  
          return ActionSupport.SUCCESS;
      }
  </code></pre>
  
  <p><strong>Inside the jsp</strong></p>
  
  <pre><code>&lt;s:form action="editCourseAction" validate="true"&gt;
   Courses: 
  
  &lt;s:iterator value="coursesMarks" status="st"&gt;
  &lt;s:label &gt;&lt;s:property value="course" /&gt;&lt;/s:label&gt;
  &lt;s:textfield name="coursesMarks[%{#st.index}].value" theme="simple"/&gt;
  &lt;br /&gt;
  
  &lt;/s:iterator&gt;
  &lt;s:submit action="editCourseAction" value="submit" /&gt;
   &lt;/s:form&gt;
  </code></pre>
  
  <p>Running this code throws this error...</p>
  
  <pre><code>    Mar 13, 2013 12:09:23 PM org.apache.catalina.core.ApplicationDispatcher invoke
  SEVERE: Servlet.service() for servlet jsp threw exception
  java.util.ConcurrentModificationException
      at java.util.HashMap$HashIterator.nextEntry(HashMap.java:793)
      at java.util.HashMap$EntryIterator.next(HashMap.java:834)
      at java.util.HashMap$EntryIterator.next(HashMap.java:832)
      at org.apache.struts2.components.IteratorComponent.end(IteratorComponent.java:334)
      at org.apache.struts2.views.jsp.IteratorTag.doAfterBody(IteratorTag.java:87)
      at org.apache.jsp.pages.editCourse_jsp._jspx_meth_s_005fiterator_005f0(editCourse_jsp.java:251)
      at org.apache.jsp.pages.editCourse_jsp._jspx_meth_s_005fform_005f0(editCourse_jsp.java:174)
      at org.apache.jsp.pages.editCourse_jsp._jspService(editCourse_jsp.java:104)
      at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
          .....and a long long list of error lines below this
  </code></pre>
  
  <p>If i use the following code</p>
  
  <pre><code>    &lt;s:iterator value="coursesMarks" &gt;
  &lt;s:label &gt;&lt;s:property value="course" /&gt;&lt;/s:label&gt;
  &lt;s:textfield name="value" theme="simple"/&gt;
  </code></pre>
  
  <p>It displays the values correctly but does not pass them back to the action class. Could you please tell me how to accomplish my task</p>