title: how to convert this java code into servlets
body: <p>I am new to servlet. I am trying to connect to database using java with JDBC and OJDBC. I have already written a java code for this. Now I need to run it on Tomcat server. So I have chosen servlet .I have done this using Netbeans IDE, there I chose servlet and I gave class name as servlet name in web.xml. I don't know where I did wrong.So, I am posting the working java code:</p>
  
  <pre><code>public class convert {
  
      int i = 0, j = 0, k = 0;
      Connection conn = null;
      Connection connection = null;
      static int count = 0;
  
      // Following variables are required for assigning resultset values from
      // excel spreadsheet
      String name[] = null;
      String Title[] = null;
  
      Statement stmt1 = null;
      ResultSet NumOfRows = null;
      Statement stmt2 = null;
      ResultSet SpreadsheetValues = null;
      Statement stmt3 = null;
      ResultSet rs3 = null;
  
      int Rowcount = 0;
  
      // this static function required to connect database
      static {
          try {
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
          } catch (ClassNotFoundException ex) {
              Logger.getLogger(spreadsheet2db.class.getName()).log(
                      Level.SEVERE, null, ex);
          }
      }
  
      // connect Sql database
      void ConnectSqlDB() throws SQLServerException, SQLException {
          // code
      }
  
      void ConnectExcelDB() throws SQLException {
          conn = DriverManager.getConnection("jdbc:odbc:condb", "", "");
      }
  
      // getRowcount() will return number of rows present in spreadsheet
      // Result of rowcount is used for array size
      void getRowcount() throws SQLException {
          // System.out.println("Number of rows in spreadsheet");
          // System.out.println(Rowcount);
      }
  
      void sheetValues() throws SQLException {
          stmt2 = conn.createStatement();
          // ExcelQueryString2 will give values of attributes
          while (SpreadsheetValues.next()) {
              // Assigning Spread sheet values to String array
              Cname[j] = SpreadsheetValues.getString("name");
              Title[j] = SpreadsheetValues.getString("Title");
              j++;
          }
      }
  
      public static void main(String args[]) throws SQLServerException,
              SQLException {
          convert a = new convert();
          a.ConnectSqlDB();
          a.ConnectExcelDB();
          a.getRowcount();
          a.sheetValues();
      }
  }
  </code></pre>
  
  <p>I want to know how can I convert this code into Servlet?</p>