title: How to pass values in a for loop from jsp to servlet and vice versa
body: <p>Is there a way to pass values from a txtbox in a for loop from JSP to servlet and back again? the following is part of the code in my jsp page</p>
  
  <pre><code>&lt;% 
   DetailsMod bean = null;
   List resultList = (List) session.getAttribute("list");
   int count1=-1;
   String value2 = "";
   if(resultList.size() &gt; 0 )  {  
   int rowNum = 1;
    for(int i=0; i&lt;resultList.size(); i++){
     bean = (DetailsMod) resultList.get(i);
  %&gt;
  &lt;input type="text" name="tbx_cost" value="&lt;%=bean.getCost()%&gt;"/&gt;
  
  &lt;% count1 = i;
  }
  }%&gt;
  </code></pre>
  
  <p>Lets say the resultList returns 2 as value, then there will be 2 textboxes. If user were to input 2000 in the first box and 3000 in the second box, how do I store this values in order for me to retrieve it in servlet? I tried using the following code in the servlet:</p>
  
  <pre><code> double cost = Double.parseDouble(request.getParameter("tbx_cost"));
  </code></pre>
  
  <p>But instead of giving me both values, it returns only the first value. Is there a way for me to solve this issue?</p>
  
  <p>Also once retrieved in servlet if user were to edit data again how do I pass back these values retrieved in servlet to JSP <code>tbx_cost</code> ?</p>