title: How to dynamically create row and column of table in jsp page
body: <p>I am trying to retrieve data from database into table.
  But data must be loaded dynamically.</p>
  
  <p>How to dynamically create row and column I don't know?
  If it will be only row to create then I will do it easily but I also want to create column dynamically on page so that's why I am confused how to perform it?</p>
  
  <p>My JSP code :</p>
  
  <pre><code>&lt;table width="59%" border="1"&gt;
      &lt;%
          MySql1 o = new MySql1();
          o.connect();
          ResultSet r;
          int counter=1;
          String q = "select * from category_master;";
          r = o.getdata(q);
          while(r.next())
          {
              %&gt;
                  &lt;tr&gt;
                       &lt;td&gt;&lt;%= r.getString(1)%&gt;&lt;/td&gt;                                      
                  &lt;/tr&gt;
              &lt;% 
          }
      %&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>Right now I am displaying first column in <code>&lt;td&gt;</code> but if the user don't know how many columns are going to be retrieved then what to do ?
  In <code>select query</code> I have used <code>*</code> so I am confused for taking <code>&lt;td&gt;</code>.
  I want to all dynamic because suppose I will pass table name also dynamically using any textbox or url.</p>
  
  <p>Here <code>MySql</code>1 is one class file that has method to perform operation.
  <code>connect()</code> is used to connect with db, and <code>getdata()</code> is used to retrieve data of query passed as argument and return type of <code>getdata()</code> method is <code>Resultset</code>.</p>
  
  <p>So that's why I want all dynamic, but I don't know how to do that.</p>