title: How to access form values in a servlet?
body: <p>I have below jsp code.</p>
  
  <pre><code>&lt;table id="myTable" border="0" cellspacing="0" style="border-spacing:0; width:100%;border-collapse: collapse;"&gt;
              &lt;%
                  List&lt;Object&gt; object = (List&lt;Object&gt;)request.getAttribute("myContact");
          for(int i=0;i&lt;object.size();i++){
                  MyModel myModel = (MyModel)object.get(i);
                  String mail = myModel.getmail()!=null ? myModel.getmail().toString().trim() : "";
                  String title = myModel.gettitle()!=null ? myModel.gettitle().toString().trim() : "";
                  String name = myModel.getname()!=null ? myModel.getname().toString().trim() : "";               
              %&gt;
  
  
              &lt;tr&gt;
              &lt;td class="table-border-bottom"&gt;&lt;label for="name"&gt;Name:&lt;/label&gt;&lt;/td&gt;
              &lt;td class="table-border-bottom"&gt;&lt;input id="name" type="text" value='&lt;%=name%&gt;' name="name" class="required" style="height: 17px;"/&gt;
              &lt;/td&gt;
              &lt;td class="table-border-bottom"&gt;&lt;label for="contactTitle"&gt;Title:&lt;/label&gt;&lt;/td&gt;
              &lt;td class="table-border-bottom"&gt; &lt;input id="title" type="text" value='&lt;%=title%&gt;' name="title" class="required" style="height: 17px;"/&gt;
  
              &lt;/td&gt;
              &lt;td class="table-border-bottom"&gt;&lt;label for="mail"&gt;Email:&lt;/label&gt;&lt;/td&gt;
              &lt;td class="table-border-bottom"&gt;&lt;input id="mail" type="text" value='&lt;%=mail%&gt;' name="mail" class="required email" style="height: 17px; "/&gt;
  
              &lt;/td&gt;
              &lt;/tr&gt;
  
      &lt;% } %&gt;
  
              &lt;tr align="center"&gt;
              &lt;td valign="bottom" colspan="6" style="height: 45px; "&gt;
              &lt;input type="button" id="submit" name="submit" value="Save" style="width: 80px ; height:24px; text-align: center;border-radius: 10px 10px 10px 10px;"/&gt; 
              &lt;input type="button" id="revert" name="revert" value="Revert" style="width: 80px ; height:24px;text-align: center;border-radius: 10px 10px 10px 10px;"/&gt;&lt;/td&gt;
              &lt;/tr&gt;
  
        &lt;/table&gt;  
  </code></pre>
  
  <p>To access form values i can write the code as below in servlet:</p>
  
  <pre><code>String name = request.getParameter("name");
      String title = request.getParameter("title");
      String email = request.getParameter("email"); 
  </code></pre>
  
  <p>But my table is populated dynamically. i will not come to know how many params it has as the form will have many fields and the form is populated by looping the list returned from db.
  Also, in the form, input names have been hard coded. As i will have many fields based on the db returned list, how can i avoid and give unique names for the input elements?</p>
  
  <p>How can i overcome this?</p>
  
  <p>Thanks!</p>