-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path로그인 유효성검사 serverlet.java
More file actions
110 lines (96 loc) · 2.86 KB
/
로그인 유효성검사 serverlet.java
File metadata and controls
110 lines (96 loc) · 2.86 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package loginform;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class selectServlet
*/
@WebServlet("/newnewLoginServlet")
public class newnewLoginServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
String url;
String userid;
String passwd;
/**
* @see HttpServlet#HttpServlet()
*/
public newnewLoginServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
url = "jdbc:oracle:thin:@localhost:1521:orcl";
userid ="system";
passwd = "human123";
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
PrintWriter out = response.getWriter();
try {
String id=request.getParameter("id");
String password=request.getParameter("password");
String sql = "select count(*) cnt from createUser where userid='"+id+"' and userpassword='"+password+"'";
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection(url,userid,passwd);
System.out.println("console1");
System.out.println(sql);
stmt = conn.createStatement();
System.out.println("console2");
rs=stmt.executeQuery(sql);
System.out.println("console3");
String str = "";
rs.next();
System.out.println("console4");
//int id=rs.getInt("id");
System.out.println("console5");
int cnt=rs.getInt("cnt");
out.print(cnt);
System.out.println(cnt);
out.close();
//out.println("<script>alert('중복된 아이디가 있습니다'); history.back();</script>");
System.out.println("console7");
System.out.println("console8");
}catch(Exception e) {
System.out.println(e);
out.println("error");
}finally {
try {
rs.close();
} catch (SQLException e) {
System.out.println(e);
e.printStackTrace();
}
try {
stmt.close();
} catch (SQLException e) {
System.out.println(e);
e.printStackTrace();
}
try {
conn.close();
} catch (SQLException e) {
System.out.println(e);
e.printStackTrace();
}
}
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}