<%--
page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>$Title$</title>
</head>
<body>
<form action="home.jsp " method="post">
<input type ="text " name="username">
<input type ="text " name="password">
<button type ="submit ">提交</button>
</form>
</body>
</html>
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/f4f9772c7bd7d8bd2da1d75e9d5b4ce4.png)
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<%
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/book";
Connection connection = DriverManager.getConnection(url ,"root","root");
String sql = "select * from user where username = ? and password = ?";
PreparedStatement ps =connection .prepareStatement(sql);
ps.setString(1,request .getParameter("username") );
ps.setString(2,request .getParameter("password") );
ResultSet rs = ps.executeQuery() ;
while (rs.next() ){
out.print(rs.getString("username")+"-"+rs.getString(5)+"<br>" );
}
%>
</body>
</html>
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/12848b32242786608ad00eb25401ff6a.png)