import java.io.IOException;
import java.sql.*;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.*;

public class InsClient extends HttpServlet
{

    public InsClient()
    {
    }

    public void service(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
        throws ServletException, IOException
    {
        httpservletresponse.setContentType("text/html");
        ServletOutputStream servletoutputstream = httpservletresponse.getOutputStream();
        int i = 1;
        try
        {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            Connection connection = DriverManager.getConnection("Jdbc:Odbc:DSN", "scott", "tiger");
            Statement statement = connection.createStatement();
            ResultSet resultset = statement.executeQuery("SELECT MAX(ENO)FROM JEMP");
            if(resultset.next())
                i = resultset.getInt(1) + 1;
            connection.close();
        }
        catch(Exception exception)
        {
            servletoutputstream.println(exception.toString());
        }
        servletoutputstream.println("<html><body bgcolor=pink>");
        servletoutputstream.println("<form action='http://localhost:7001/Insert.jsp'>");
        servletoutputstream.println((new StringBuilder()).append("Emp No <input name='ENO' value=").append(i).append("><br>").toString());
        servletoutputstream.println("Emp Name <input name='ENAME'><br>");
        servletoutputstream.println("Basic Pay <input name='BASIC'><br>");
        servletoutputstream.println("<input name=submit value=Insert type=submit>");
    }
}