title: Step by Step How to create insert Data in postgresql with a form in Java
body: <p>I am really new in Java (ok, totally brad new) and I'm trying to create a very basic form let's say just name and last name with Java and introduce the data in my postgresql database.</p>
  
  <p>I need some step by step instructions on how to do it.</p>
  
  <p>This is my understanding but I have questions in surly miss-conceptions:</p>
  
  <ol>
  <li><p>HTML file with Form</p>
  
  <pre><code>&lt;HMTL&gt;
  &lt;body&gt;
  &lt;form action=servlet" method="get"&gt;
  Name: &lt;input type="text" name="name"&gt;&lt;br&gt;
  Last Name: &lt;input type="text" name="lastname"&gt;&lt;br&gt;
  &lt;input type="submit" value="Submit"&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre></li>
  <li><p>Have the servlet file (First question: Is this a servlet.java or servlet.class file?)</p></li>
  </ol>
  
  <p>Second question: whether is a .java or .class file, can I create and edit those files in a regular text editor? gedit in Ubuntu for instance? or do I need something like Eclipse? </p>
  
  <p>Third question: to debug the code, I guess I need Eclipse or other debugger.</p>
  
  <p>Forth question: How do I call the servlet.java or .class file from HTML? I have this in the HTML () but that will perform the connection to the Database as well?</p>
  
  <p>And I I have to establish the connection to the Database </p>
  
  <pre><code>    import java.io.IOExcetion;
      import javax.servlet.ServletException;
      import javax.servlet.http.HttpServlet;
      import javax.servlet.http.HttpServletRequest;
      import javax.servlet.http.HttpServletResponse;
  
      import java.sql.Connection;
      import java.sql.DriverManager;
      import java.sql.Statement;
  
      public class servletExample extends HttpServlet{
      protected void doGet (HttpServletRequest reg, HttpSevletR
           throws ServletException, IOException {
         String name = req.getParameter ("name");
         String name = req.getParameter ("lastname");
           }
       }
  
      public class PostgreSQLJDBC {
         public static void main(String args[]) {
            Connection c = null;
            Statement stmt = null;
            try {
       Class.forName("org.postgresql.Driver");
       c = DriverManager
          .getConnection("jdbc:postgresql://localhost:5432/testdb",
          "user", "password");
       c.setAutoCommit(false);
       System.out.println("Opened database successfully");
  
       stmt = c.createStatement();
       String sql = "INSERT INTO USERS (name, lastname) ";
       stmt.executeUpdate(sql);
  
       stmt.close();
       c.commit();
       c.close();
       } catch (Exception e) {
       System.err.println( e.getClass().getName()+": "+ e.getMessage() );
       System.exit(0);
      }
        System.out.println("Records created successfully");
         }
      }
  </code></pre>
  
  <ol start="3">
  <li>I run my HTML file in the server: (If html file is index.html) localhost/index.html</li>
  </ol>
  
  <p>This will show in my browser a form asking for name and lastname and a submit button and when clicking submit, it will introduce the values in the database.</p>
  
  <p>THANK YOU SO MUCH FOR ALL YOUR HELP!!!!!!!!!!!</p>