<%@ page language="java" import="java.sql.*" pageEncoding="UTF-8"%> <html> <head><title>everything</title> </head> <body> <% String driverName = "com.mysql.jdbc.Driver"; String userName = "root"; String userPwd = "123456"; String dbName = "students"; String url1 = "jdbc:mysql://localhost:3306/"+dbName; String url2 = "?user=" +userName + "&password = " + userPwd; String url3 = "&useUnicode = true & characterEncoding = UTF-8"; String url = url1 + url2 + url3; try{ Class.forName(driverName); Connection conn = DriverManager.getConnection(url1,"root","123456"); String sql = "select pwd from user where ID = ?"; PreparedStatement pstmt = conn.prepareStatement(sql); String ID = request.getParameter("ID"); pstmt.setString(1,ID); ResultSet rs = pstmt.executeQuery(); String pwd = rs.getString("pwd"); String Dpwd = request.getParameter("ipwd"); rs.close(); pstmt.close(); conn.close(); if(pwd.equals(Dpwd)) %> <jsp:forward page = "access.jsp"/> <% }catch(SQLException e){e.printStackTrace();}%> </body> </html>