title: retrieve data from database in same jsp file into the table
body: <p>hi i am using jsp and servlets and my problem is to retrieve the data from database into the same jsp file i had two tables in jsp file.i want to get the data into the second table.so please help me frnds.below is my code </p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;%@page import="com.sun.xml.internal.txw2.Document"%&gt;&lt;html&gt;
  &lt;%@page import="java.io.IOException" %&gt;
  &lt;%@page import="java.io.PrintWriter" %&gt;
  &lt;%@page import="java.sql.Connection" %&gt;
  &lt;%@page import="java.sql.DriverManager" %&gt;
  &lt;%@page import="java.sql.Statement" %&gt;
  &lt;%@page import="java.sql.ResultSet" %&gt;
  &lt;%@page import="javax.servlet.ServletException" %&gt;
  &lt;%@page import="javax.servlet.http.HttpServlet" %&gt;
  &lt;%@page import="javax.servlet.http.HttpServletRequest" %&gt;
  &lt;%@page import="javax.servlet.http.HttpServletResponse" %&gt;
  
  second table
  
  &lt;%  
  Class.forName("com.mysql.jdbc.Driver");
  
  System.out.println("driver loaded");
  System.out.println("Driver is loaded");
  Connection con= (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/charms?user=root&amp;password=root");
  System.out.println("Connection created");
  Statement stmt = con.createStatement();
  ResultSet rs = stmt.executeQuery("select * from dealer_masters");%&gt;
  
  &lt;table align="center" border="1"&gt;
  
    &lt;tr&gt;
      &lt;td&gt;Dealer Id&lt;/td&gt;
      &lt;td&gt;Dealer Name&lt;/td&gt;
      &lt;td&gt;Door no&lt;/td&gt;
      &lt;td&gt;Street&lt;/td&gt;
      &lt;td&gt;City&lt;/td&gt;
      &lt;td&gt;District&lt;/td&gt;
      &lt;td&gt;State&lt;/td&gt;
      &lt;td&gt;Mobile&lt;/td&gt;
      &lt;td&gt;Contact Person&lt;/td&gt;
      &lt;td&gt;Phone No&lt;/td&gt;
  
    &lt;/tr&gt;
     &lt;% while (rs.next()) {%&gt;
    &lt;tr&gt;
     &lt;td&gt;&lt;%=rs.getString("deal_id_v")%&gt;&lt;/td&gt;
      &lt;td &gt;&lt;%=rs.getString("deal_name_v") %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%=rs.getString("deal_door_no_v") %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%=rs.getString("deal_street_v") %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= rs.getString("deal_city_v") %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= rs.getString("deal_district_v")%&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= rs.getString("deal_state_v")%&gt;&lt;/td&gt;
      &lt;td &gt;&lt;%=rs.getString("deal_mobile_no_v")%&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%=rs.getString("deal_contactperson_v") %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%=rs.getString("deal_phone_no_v") %&gt;&lt;/td&gt;
  
    &lt;/tr&gt;
   &lt;%}%&gt;
  &lt;/table&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>