title: Edit button on a dynamic table in jsp servlet application
body: <p>I am working on a JSP Servlet project in which I have created a table on the JSP page. This table is getting populated from an arraylist that is the resultset of a query. So I am basically running a query, storing into an arraylist and displaying the values from that arraylist. How should I edit the fields in the table such that I can delete all information about that field from the table and create a new entry entered by the user.</p>
  
  <p>The code for JSP page to run the query and display the table is as follows:</p>
  
  <pre><code>//run the query
  try{
      out.println("&lt;html&gt;");
      out.println("&lt;table id='tbl'class= 'cls' style='display;' border=''&gt;&lt;tr&gt;&lt;th&gt;Tag&lt;/th&gt;&lt;th&gt;Severity&lt;/th&gt;&lt;th&gt;Threshold&lt;/th&gt;&lt;th&gt;ID&lt;/th&gt;&lt;th id= 'del'&gt;Delete&lt;/th&gt; &lt;/tr&gt;");
      Iterator&lt;String&gt; li = alarmarr.iterator();   
      int flagy=1;
      int temp = 1;
  
      for (int f=0; f&lt;=count; f++){
          out.println("&lt;tr&gt;");
          while(li.hasNext() &amp;&amp; temp &lt;=numberOfColumns){
              temp++;
              String temporaryvalue = (String)li.next();
              out.println("&lt;td&gt;&lt;input type='text' value='"+temporaryvalue+"' /&gt;&lt;/td&gt;");
  
              if(temp ==5 &amp;&amp; flagy==1){
                  out.println("&lt;td&gt; &lt;a href='editalarm?id="+temporaryvalue+"'&gt;Edit&lt;/a&gt;&lt;/td&gt;");
                  out.println("&lt;td id = 'delalarms' &gt; &lt;a  id='delalarms' href='deletealarm?id="+temporaryvalue+"'&gt;Delete&lt;/a&gt;&lt;/td&gt;");
                  flagy = 0;  
              }
          }
          temp = 1;
          flagy = 1;
          out.println("&lt;/tr&gt;");
  
      }
      out.println("&lt;/table&gt;&lt;/div&gt;");
      out.println("&lt;/center&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;"); 
  
  }
  catch(Exception e)
  {
      System.out.println(e);
  }
  </code></pre>