Following is a Servlet that is called from a HTML form with 3 fields (login, password, name). It will add the user into the database.

Java Code:
public void doPost(HttpServletRequest request, HttpServletResponse response) 
throws ServletException, IOException {
response.setContentType(CONTENT_TYPE);
String str_login = request.getParameter("login");
String str_pass = request.getParameter("password");
String str_name = request.getParameter("name");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>Servlet_Register</title></head>");
out.println("<body bgcolor=\"#ffffff\">");
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:mydsn");
Statement st = con.createStatement();


int i= st.executeUpdate("insert into login values('"+str_login+"','"+str_pass+
                          "','"+str_name+"'," + 0  +")");
out.println(str_login +"is now registered.");
out.println("<p align=\"center\"><a href=\"login.htm\">sign in</a></p>");
}catch(Exception ee){System.out.println("2nd"+ee);}
}
out.println("</body></html>");