title: Retrieve an array of parameters from a servlet
body: <p>I want to retrieve the parameter entered in my inputs of type text. The problem is they have been given names depending of the forEach and I cant find a way to retrieve from my servlets.</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
    &lt;html&gt;
         &lt;head&gt;
            &lt;meta charset="utf-8" /&gt;
            &lt;title&gt;Editer les sous-titres&lt;/title&gt;
        &lt;/head&gt;
        &lt;body&gt;
            &lt;form method="post"&gt;    
            &lt;input type="submit" value="Envoyer"  style="position:fixed; top: 10px; right: 10px;" /&gt;
            &lt;table&gt;
              &lt;c:forEach items="${ subtitles }" var="line" varStatus="status"&gt;
                  &lt;tr&gt;
                      &lt;td&gt;&lt;c:out value="line${ status.index }"&gt;&lt;/c:out&gt;&lt;/td&gt;
                      &lt;td style="text-align:right;"&gt;&lt;c:out value="${ line }" /&gt;
                                                                            &lt;/td&gt;
                      &lt;td&gt;&lt;input type="text" name="line${ status.index }" id="line${ status.index }" size="35" value="&lt;c:out value='${ traductions }'&gt;&lt;/c:out&gt;" /&gt;&lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/c:forEach&gt;
          &lt;/table&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>This is the code for my servlets :</p>
  
  <pre><code>package com.subtitlor.servlets;
  
  import java.io.IOException;
  
  import javax.servlet.ServletContext;
  import javax.servlet.ServletException;
  import javax.servlet.annotation.WebServlet;
  import javax.servlet.http.Cookie;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  import com.subtitlor.beans.Traduire;
  import com.subtitlor.dao.DaoFactory;
  import com.subtitlor.dao.SubtitlorDao;
  import com.subtitlor.utilities.SubtitlesHandler;
  
  @WebServlet("/EditSubtitle")
  public class EditSubtitle extends HttpServlet {
      private static final long serialVersionUID = 1L;
      private static final String FILE_NAME = "/WEB-INF/password_presentation.srt";
      private SubtitlorDao subtitlorDao;
  
      public void init() throws ServletException {
          DaoFactory daoFactory = DaoFactory.getInstance();
          this.subtitlorDao = daoFactory.getUtilisateurDao();
      }
  
      protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          ServletContext context = getServletContext();
          System.out.println(context.getRealPath(FILE_NAME));
          SubtitlesHandler subtitles = new SubtitlesHandler(context.getRealPath(FILE_NAME));
          request.setAttribute("subtitles", subtitles.getSubtitles());
  
          for(int i=0;i&lt;688;i++)
          {
              Cookie[] cookies = request.getCookies();
              if(cookies != null)
              {
                  for(Cookie cookie : cookies)
                  {
                      if(cookie.getName().equals("traduction[i]"))
                      {
                          request.setAttribute("traductions", cookie.getValue());
                      }
                  }
              }
          }
  
          this.getServletContext().getRequestDispatcher("/WEB-INF/edit_subtitle.jsp").forward(request, response);
      }
  
      protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          Traduire trad = new Traduire();
  
          String[] line= new String[688];
  
          for(int i=0;i&lt;688;i++)
          {   
              line[i]=request.getParameter("line"+i);
              trad.setTraduction(line[i]);
              subtitlorDao.ajouter(trad);
  
              Cookie cookie = new Cookie("traduction[i]", line[i]);
              cookie.setMaxAge(60 * 60 * 24 * 30);
              response.addCookie(cookie);
  
              Cookie[] cookies = request.getCookies();
              if(cookies != null)
              {
                  for(Cookie cookiee : cookies)
                  {
                      if(cookiee.getName().equals("traduction[i]"))
                      {
                          request.setAttribute("traductions", cookiee.getValue());
                      }
                  }
              }
          }   
  
          this.getServletContext().getRequestDispatcher("/WEB-INF/edit_subtitle.jsp").forward(request, response);
      }
  
  }
  </code></pre>