title: How to create a table after inserting data in JSP and also save that data to mysql through java
body: <p>I have built a page of jsp where I have taken inputs from the user and created a table from that input now I have to show that table on another page and also I have to create that table in mysql simultaneously through Java.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>&lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;title&gt;Dynamic table&lt;/title&gt;
  &lt;script src ="https://code.jquery.com/jquery-3.3.1.min.js"&gt;&lt;/script&gt;
  &lt;SCRIPT language="javascript"&gt;
  
   var counter=2;
   function addRow(tableID){
    var dynamicVal = 'row'+counter;
    $('#dataTable').append('\
    &lt;TR&gt;\
     &lt;TD&gt;&lt;INPUT type="checkbox" name="'+dynamicVal+'_chk" id="'+dynamicVal+'_chk"/&gt;&lt;/TD&gt;\
     &lt;TD&gt;&lt;INPUT type="text" name="'+dynamicVal+'_col" id="'+dynamicVal+'_col" required/&gt;&lt;/TD&gt;\
     &lt;TD&gt;\
      &lt;SELECT name="'+dynamicVal+'_datatype" id="'+dynamicVal+'_datatype"&gt;\
       &lt;OPTION value="int"&gt;INT(40)&lt;/OPTION&gt;\
       &lt;OPTION value="var"&gt;VARCHAR(40)&lt;/OPTION&gt;\
       &lt;OPTION value="char"&gt;CHAR(40)&lt;/OPTION&gt;\
      &lt;/SELECT&gt;\
     &lt;/TD&gt;\
    &lt;/TR&gt;');
    counter++; 
   }
   
   function deleteRow(tableID){
   /*$('#dataTable').find('[INPUT type="checkbox"]').each(function(){\
   if($this).prop("checked") == true({
   ($this).closest('tr').remove();
   }
   });*/
     
     $('#dataTable').find('tr').each(function(){
     if($(this).find('input[type="checkbox"]').prop('checked') == true){
       $(this).remove();
      }
      
     }); 
   
   
   }
   
   function createJSON() {
    
   var obj ={};
   obj.table_name=$("input[id=table_name]").val();
   var rowcolms = {};
   var rowcollection = [];
   $('#dataTable').find('tr').each(function(){
    var row = {};
    row.colName=$(this).find('input[type="text"]').val();
    row.dataType = $(this).find('select').val();
    rowcollection.push(row);
   });
   obj.tablecolms=rowcollection;
       /*var col_name = $(this).val("text");
    var datatype = $(this).type("select");
  
          item = {}
          item ["text"] = "col_name" ;
          item ["select"] = "datatype";
  
          jsonObj.push(item);
      });
   $*/
     console.log(obj);
     
  }
  
  function ajaxcall(){
   $.get.json({
     url: Createdatabase,
     type:"post",
     data: jsonObj,
     success: function(data){
     console.log(data);
     }
   });
  }
   
  
   &lt;/SCRIPT&gt;
  &lt;/head&gt;
  &lt;style&gt;
    body {
      background-color : #D3D3D3;
      margin: 0;
      padding: 0;
  }
  h4 {
      color : #000000;
      text-align : center;
      font-family: "SIMPSON";
  }
  form {
      width: 300px;
      margin: 0 auto;
  }
  &lt;/style&gt;
  &lt;body&gt;
  &lt;form&gt;
  &lt;h4&gt;Create Your Table&lt;/h4&gt;
  &lt;form action="servlet/createdatabase" method="post"&gt; 
  Table Name: &lt;input type="text" name="table_name" id="table_name"required&gt;
  &lt;input type="submit" value="Submit"&gt;&lt;br&gt;&lt;br&gt;
  &lt;h4&gt;Design Your Table&lt;/h4&gt;
  &lt;INPUT type="button" value="Add Row" onclick="addRow('dataTable')" /&gt;
  
   &lt;INPUT type="button" value="Delete Row" onclick="deleteRow('dataTable')" /&gt;
  
   &lt;TABLE id="dataTable" name="dataTable" width="350px" border="1"&gt;
    &lt;TR&gt;
     &lt;TD&gt;&lt;INPUT type="checkbox" name="row1_chk" id="row1_chk"/&gt;&lt;/TD&gt;
     &lt;TD&gt;&lt;INPUT type="text" name="row1_col" id="row1_col" required/&gt;&lt;/TD&gt;
     &lt;TD&gt;
      &lt;SELECT name="row1_datatype" id="row1_datatype" type="select"&gt;
       &lt;OPTION value="int"&gt;INT(40)&lt;/OPTION&gt;
       &lt;OPTION value="var"&gt;VARCHAR(40)&lt;/OPTION&gt;
       &lt;OPTION value="char"&gt;CHAR(40)&lt;/OPTION&gt;.
      &lt;/SELECT&gt; 
     &lt;/TD&gt;
    &lt;/TR&gt;
   &lt;/TABLE&gt;&lt;br&gt;
  &lt;input type="button" value="Create Table" onclick="ajaxcall'"&gt;
  
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>So please can anyone tell that how can I create this table on another page and also in the format of tables and create this table in mysql?</p>