-
Notifications
You must be signed in to change notification settings - Fork 0
/
loginCheck.jsp
40 lines (29 loc) · 1.04 KB
/
loginCheck.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8" %>
<%@ page import="java.util.*" import="java.sql.*" %>
<%
request.setCharacterEncoding("utf-8");
%>
<jsp:useBean id="doctor" class="com.project.DoctorInfo"></jsp:useBean>
<jsp:setProperty property="*" name="doctor"/>
<%
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8";
Connection conn = DriverManager.getConnection(url,"root","root");
Statement stmt = conn.createStatement();
String sql = "select * from doctor";
ResultSet rs = stmt.executeQuery(sql);
while(rs.next() == true) {
if(rs.getString("name").equals(doctor.getName())){
if(rs.getString("pwd").equals(doctor.getPwd())){
session.setAttribute("name",doctor.getName());
response.sendRedirect("inter_index.jsp");
} else {
response.sendRedirect("index.jsp?para=1");
}
}
}
%>
<script>
window.location.href = "index.jsp?para=2";
</script>