title: Setting ArrayList as an attribute in servlet and accessing in jsp
body: <p>I'm trying   to set a Array list of String to an attribute of session in servlet, and try to access this Array list of Attributes in jsp.
  But just one value(last value) access in jsp.
  i want to access All list of attribute.</p>
  
  <p>i searched too much here and there but i don't found about my question.</p>
  
  <p><strong>form jsp:</strong></p>
  
  <pre><code>&lt;form action="/CompleteServlet" method="get"&gt;
  &lt;%String completeTasks=((ArrayList&lt;String&gt;)session.getAttribute("todoList")).get(i);%&gt;
   &lt;input type="hidden" name="completeTasks" value="&lt;%=completeTasks%&gt;" /&gt;
   &lt;input type="submit" value="Completed"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>from CompleteServlet :</strong></p>
  
  <pre><code> String v=req.getParameter("completeTasks");
          HttpSession session=req.getSession();
  
          ArrayList&lt;String&gt; arrOfCompleteTask = new ArrayList&lt;&gt;();
          arrOfCompleteTask.add(v);
          session.setAttribute("completeTasks", arrOfCompleteTask);
  
          req.getRequestDispatcher("/complete.jsp").forward(req,resp);
  </code></pre>
  
  <p><strong>form complete.jsp</strong></p>
  
  <pre><code>&lt;%
  int size=((List&lt;String&gt;)session.getAttribute("tryCom")).size();
      for(int i=0;i&lt;size;i++)
          {%&gt;
  &lt;%=((List&lt;String&gt;)session.getAttribute("tryCom")).get(i)%&gt;``
         &lt;%}%&gt;
  </code></pre>