} JSP中的使用方法 ------------------------------------------------------------------------------- <%@ page language='java' %> <jsp:useBean id='oMD5' scope='request' class='beartool.MD5'/> <%@ page import='java.util.*'%> <%@ page import='java.sql.*'%> <html> <body> <% String userid = request.getParameter("UserID"); //获取用户输入UserID String password = request.getParameter("Password"); //获取用户输入的Password String pwdmd5 = oMD5.getMD5ofStr(password); //计算MD5的值 PrintWriter rp = response.getWriter(); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("jdbc:odbc:community", "", ""); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("select * from users where userID ='"+userid+"' and pwdmd5= '" + pwdmd5+"'" ); if (rs.next()) { rp.print("Login OK"); } else { rp.print("Login Fail"); } |