-1

I am using this code to get form data used inside jsp Form.

String product=request.getParameter("product");
String qty=request.getParameter("quantity");
String price=request.getParameter("price");
writer.println(product  +" "+qty+"  "+price);

How Ever i am using dynamic form.How do i can get all datas in controller class.
Here is the code of view class i.e jsp Pages.

  <script>
 $(document).ready(function(){
   $("button").on("click", function(){
     var row = '<tr><td><input type="text" name="product" value="product..">'+
    '</input></td><td><input type="number" name="quantity" value="quanty..">' +
   ' </input></td><td><input type="number" name="price" value="price.."> </input></td></tr>';
     $("#customers").append(row);
   });
 });
</script>
</head>
<body>
  <button type="button">Add More Products</button>
  <form action="XmlServlet" method="get">
   <table id="customers">
 <tr>
 <th>Product</th>
 <th>Quantity</th>
 <th>Price</th>
 </tr>
  <tr>
     <td><input type="text" name="product" value="product.."></input>    </td>
    <td><input type="number" name="quantity" value="quanty.."></input></td>
    <td><input type="number" name="price" value="price.."></input></td>
  </tr>
             <tr>
               <td><input type="submit"></td>
            </tr>
            </table>
             </form>

How do i can get all data's saved in text field after add more button action's.

Pritam Tiwari
  • 19
  • 1
  • 3

1 Answers1

0
String[] products = request.getParameterValues("product");
JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255