title: How to pass an arraylist from one servlet to another servlet
body: <p>I have two Servlets, In first servlet I am creating an arraylist and paasing it to jsp page to display on UI, now I want to pass the same arraylist from the first servlet to another servlet. Below is the code forArraylist of first serlet. 
  How to pass it to anather servlet in post method</p>
  
  <pre><code>protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  
      String startName=request.getParameter("startName");
      int noOfSenders=Integer.parseInt(request.getParameter("noOfSenders"));
      String domain =request.getParameter("domain");
  
      /*Code for List form function*/
      List&lt;String&gt; mails=new ArrayList&lt;String&gt;();
  
              for(int i=1;i&lt;=noOfSenders;i++){
                  StringBuilder sb = new StringBuilder(); 
                  sb.append(startName).append(i).append(domain); 
                  mails.add(sb.toString());
              }
              System.out.println("response");
              response.getWriter().write(new Gson().toJson(mails));
                          }
  </code></pre>