How to create dynamic table using html and java servlet?
<p>I have a mysql table which stores tax information. Here is how it looks. <a href="https://i.stack.imgur.com/bF81p.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bF81p.png" alt="enter image description here"></a></p>

<p>Currently I am using html/servlet to display the table but in a very ineffective way as shown in this image below. </p>

<p><a href="https://i.stack.imgur.com/XPVOd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XPVOd.png" alt="enter image description here"></a></p>

<p>View tax information shows the table when there is value in the mysql table, as follows:</p>

<p><a href="https://i.stack.imgur.com/tbuE6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tbuE6.png" alt="enter image description here"></a></p>

<p>And if the user wishes to edit that, they must click the "Edit Tax Information" button which looks takes you to this: </p>

<p><a href="https://i.stack.imgur.com/e194c.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/e194c.png" alt="enter image description here"></a></p>

<p>Is there an effective way to do all this functionality? Simply like this: </p>

<p><a href="https://i.stack.imgur.com/yfFag.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yfFag.png" alt="enter image description here"></a></p>

<p>Sample Code: </p>

<p>html:</p>

<pre><code>&lt;div id="container"&gt;
&lt;h1&gt;Add Tax Bracket&lt;/h1&gt;
&lt;form action ="AddTax" method = "post"&gt; 


    &lt;table border ="1"&gt; 

    &lt;tr&gt;
    &lt;td&gt;Tax Bracket&lt;/td&gt;
    &lt;td&gt;&lt;input type = "number" name = "bracket" min="0" step="1"  required&gt;&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
    &lt;td&gt;From Salary($)&lt;/td&gt;
    &lt;td&gt;&lt;input type = "number" name = "FromSalary" min="0" step="0.01"  required&gt;&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
    &lt;td&gt;To Salary($)&lt;/td&gt;
    &lt;td&gt;&lt;input type = "number" name = "ToSalary" min="0" step="0.01"  required&gt;&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
    &lt;td&gt;Tax Rate(%)&lt;/td&gt;
    &lt;td&gt;&lt;input type = "number" name = "rate" min="0" step="0.01"  required&gt;&lt;/td&gt;
    &lt;/tr&gt;

    &lt;/table&gt;
    &lt;br&gt;
    &lt;br&gt;
    &lt;input type = "submit" value = "Add Tax Bracket"&gt;
    &lt;/form&gt;

    &lt;h1&gt;Remove Tax Bracket&lt;/h1&gt;

    &lt;form action ="RemoveTax" method = "post"&gt; 
    &lt;table border ="1"&gt; 

    &lt;tr&gt;
    &lt;td&gt;Tax Bracket to remove&lt;/td&gt;
    &lt;td&gt;&lt;input type = "number" name = "bracket1" min="0" step="1"  required&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;/table&gt;
    &lt;br&gt;
    &lt;br&gt;
    &lt;input type = "submit" value = "Remove Tax Bracket"&gt;
    &lt;/form&gt;

    &lt;/div&gt;
&lt;/body&gt;

&lt;/html&gt;
</code></pre>

<p>Servlet:</p>

<pre><code>    String bracket = request.getParameter("bracket"); 
    String from = request.getParameter("FromSalary");
    String to = request.getParameter("ToSalary"); 
    String rate = request.getParameter("rate"); 

    try { 
         Class.forName("com.mysql.jdbc.Driver").newInstance(); 
         Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/payroll_system", "root", ""); 
         PreparedStatement ps = con.prepareStatement("INSERT INTO payroll_system.tax_info(TaxBracket, FromSalary, ToSalary, TaxPercentage) values(?,?,?,?)"); 
         ps.setString(1, bracket);
         ps.setString(2, from);
         ps.setString(3, to);
         ps.setString(4, rate);

         int count = ps.executeUpdate(); 
</code></pre>