先做个登录页面,然后发送到后台。
后台处理:
  //接收数据
   String number=request.getParameter("number");
   String password=request.getParameter("password");
  //验证是否为空
   if(number.length()==0||password.length()==0)
       out.println("number or password not null");
   else{
  try{
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
       String url="jdbc:odbc:xld";
                Connection con=DriverManager.getConnection(url,"sa","");
       //查询密码
       PreparedStatement select_stm=con.prepareStatement("
                select password from table where number=?");
                //设置参数
       select_stm.setString(1,number);
                //查询
       ResultSet result=select_stm.executeQuery();
                //获得数据库中的密码
                if(result.next())
  String temp_password=result.getString(1);
                //比较密码
                if(temp_password.regionMatches(0,password,
                  0,temp_password.length())){
                       //成功
                  }
                else       //失败
           }catch(Exception e){
  out.println(e);
  }