title: servlets connectivity & running on tomcat
body: <p>How can I use this path: <code>"file:///E:/apache-tomcat-7.0.10/webapps/examples/WEB-INF/match.html"</code> ? Is this correct?</p>
  
  <p>This is my html file:</p>
  
  <pre><code>&lt;html&gt;
      &lt;form method=post action="../classes/match1"&gt;
      &lt;body bgcolor="powderblue"&gt;
          &lt;center&gt;&lt;h1&gt;MATCH&lt;/h1&gt;
          &lt;hr/&gt;
  
          MATCH NO         &lt;input type="text" name="op1"/&gt;&lt;br/&gt;&lt;pre&gt;
          DATE             &lt;input type="text" name="op2"/&gt;&lt;br/&gt;&lt;pre&gt;
          CITY            &lt;input type="text" name="op3"/&gt;&lt;br/&gt;&lt;pre&gt;
          TEAM1            &lt;input type="text" name="op4"/&gt;&lt;br/&gt;&lt;pre&gt;
          TEAM2            &lt;input type="text" name="op5"/&gt;&lt;br/&gt;&lt;pre&gt;
          STADIUM          &lt;input type="text" name="op6"/&gt;&lt;br/&gt;&lt;pre&gt;
          WINNER           &lt;input type="text" name="op7"/&gt;&lt;br/&gt;&lt;pre&gt;
          MAN OF THE MATCH &lt;input type="text" name="op8"/&gt;&lt;br/&gt;&lt;pre&gt;
          &lt;input type="submit" value="submit"/&gt;&amp;nbsp
          &lt;input type="reset" value="reset"/&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>My servlet code:</p>
  
  <pre><code>import javax.servlet.http.HttpServlet;
  import java.io.*;
  import java.util.*;
  import java.sql.*;
  import java.sql.Date.*;
  import javax.servlet.*;
  import javax.servlet.http.*;
  public class match1 extends HttpServlet {
      Connection con;
      PreparedStatement pst;
  
      public void doPost(HttpServletRequest req,HttpServletResponse res)throws ServletException {
          try {
              PrintWriter out=res.getWriter();
              con=null;
              pst=null;
              Class.forName("oracle.jdbc.driver.OracleDriver");
              con=DriverManager.getConnection("jdbc:odbc:gan","scott","tiger");
              int count=0;
              String op1=req.getParameter("op1");
              String op2=req.getParameter("op2");
              String op3=req.getParameter("op3");
              String op4=req.getParameter("op4");
              String op5=req.getParameter("op5");
              String op6=req.getParameter("op6");
              String op7=req.getParameter("op7");
              String op8=req.getParameter("op8");
              pst=con.prepareStatement("insert into matchdetails values(?,?,?,?,?,?,?,?)");
              pst.setString(1,op1);
              pst.setString(2,op2);
              pst.setString(3,op3);
              pst.setString(4,op4);
              pst.setString(5,op5);
              pst.setString(6,op6);
              pst.setString(7,op7);
              pst.setString(8,op8);
              out.println("&lt;html&gt;&lt;center&gt;&lt;body&gt;matched&lt;/body&gt;&lt;/center&gt;&lt;/html&gt;");
              int count1=pst.executeUpdate();
              if(count1==0) {
                  out.println("&lt;html&gt;&lt;center&gt;&lt;body&gt;ENTER ALL FIELD VALUES&lt;/body&gt;&lt;/center&gt;&lt;/html&gt;");
              } else {
                  out.println("&lt;html&gt;&lt;center&gt;&lt;body&gt;INSERTION SUCCESFUL&lt;/body&gt;&lt;/center&gt;&lt;/html&gt;");
              }
          } catch (Exception e) {
              e.printStackTrace();
          } finally {
              try {
                  if (con!=null) con.close();
              } catch(Exception e) {
                  System.out.println("error");
              }
          }
      }
  }
  </code></pre>