title: Trying to retrieve arraylist from session in servlet
body: <p>I'm using HttpSession to store ArrayList <code>userList</code> as session attribute from original Servlet before passing it to JSP. It is then called in the next JSP and then called to another Servlet from that JSP.</p>
  
  <p>Servlet 1 -> JSP1 -> JSP2 -> Servlet 2</p>
  
  <p>In Servlet 1, I've set it to session :</p>
  
  <pre><code>if (!userList.isEmpty()) {
      session.setAttribute("userList", userList); 
  }    
  </code></pre>
  
  <p>I iterate it in JSP 1 and JSP 2 and call it again in Servlet 2. I need the ArrayList to be used as a parameter in another method in servlet 2.</p>
  
  <pre><code>EditStudentForm edt = (EditStudentForm)form;
  List&lt;UserApplication&gt; studtList = new ArrayList&lt;UserApplication&gt;();
  if ((session.getAttribute("userList")) instanceof List){
      studtList = (ArrayList&lt;UserApplication&gt;)request.getSession().getAttribute("userList");
  }
  try {
      uaDAO.editUser(edt,studtList);
      action_forward = EDITSUCCESS;
  }
  </code></pre>
  
  <p>It looks like the casting is not really working because the size of the ArrayList is 1 (I'm expecting a size of at least 30)</p>
  
  <p>What am I doing wrong?</p>