質問編集履歴
3
文字追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -13,7 +13,34 @@
|
|
13
13
|
```
|
14
14
|
Servletのコード
|
15
15
|
```Servletコード
|
16
|
+
/**
|
17
|
+
* Servlet implementation class LoginServlet_
|
18
|
+
*/
|
19
|
+
@WebServlet("/manager-login-servlet")
|
20
|
+
public class ManagerLoginServlet extends HttpServlet {
|
21
|
+
private static final long serialVersionUID = 1L;
|
16
22
|
|
23
|
+
/**
|
24
|
+
* @see HttpServlet#HttpServlet()
|
25
|
+
*/
|
26
|
+
public ManagerLoginServlet() {
|
27
|
+
super();
|
28
|
+
// TODO Auto-generated constructor stub
|
29
|
+
}
|
30
|
+
|
31
|
+
/**
|
32
|
+
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
|
33
|
+
*/
|
34
|
+
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
35
|
+
// TODO Auto-generated method stub
|
36
|
+
response.getWriter().append("Served at: ").append(request.getContextPath());
|
37
|
+
}
|
38
|
+
|
39
|
+
/**
|
40
|
+
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
|
41
|
+
*/
|
42
|
+
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
43
|
+
// TODO Auto-generated method stub
|
17
44
|
//DAO作成
|
18
45
|
UserDao dao = new UserDao();
|
19
46
|
|
2
文字の修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -50,6 +50,8 @@
|
|
50
50
|
rd.forward(request, response);
|
51
51
|
|
52
52
|
```
|
53
|
+
elseとcatchの遷移先はとりあえずloginJSPにしています。
|
54
|
+
|
53
55
|
JSPのコード
|
54
56
|
```
|
55
57
|
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
1
文字の修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -11,10 +11,74 @@
|
|
11
11
|
|
12
12
|
説明 オリジンサーバーは、ターゲットリソースの現在の表現を見つけられなかったか、またはそれが存在することを開示するつもりはありません。
|
13
13
|
```
|
14
|
+
Servletのコード
|
15
|
+
```Servletコード
|
14
16
|
|
17
|
+
//DAO作成
|
18
|
+
UserDao dao = new UserDao();
|
15
19
|
|
20
|
+
//ID password取得
|
21
|
+
String manager_id = request.getParameter("manager_id");
|
22
|
+
String manager_password = request.getParameter("manager_password");
|
16
23
|
|
24
|
+
//リスト作成
|
17
|
-
|
25
|
+
List<ManagerUserBean> m_user = new ArrayList<>();
|
18
26
|
|
27
|
+
|
28
|
+
//セッション作成
|
29
|
+
HttpSession session = request.getSession();
|
30
|
+
|
31
|
+
//遷移先初期化
|
32
|
+
String url;
|
33
|
+
|
34
|
+
try {
|
35
|
+
if(dao.Managerlogin(manager_id, manager_password)) {
|
36
|
+
session.setAttribute("maneger_id", manager_id);
|
37
|
+
m_user = dao.selectAll1();
|
38
|
+
session.setAttribute("m_user", m_user);
|
39
|
+
url = "menu.jsp";
|
40
|
+
}
|
41
|
+
else {
|
42
|
+
url = "manager-login.jsp";
|
43
|
+
}
|
44
|
+
} catch (ClassNotFoundException | SQLException e) {
|
45
|
+
url = "manager-login.jsp";
|
46
|
+
e.printStackTrace();
|
47
|
+
}
|
48
|
+
|
49
|
+
RequestDispatcher rd = request.getRequestDispatcher(url);
|
50
|
+
rd.forward(request, response);
|
51
|
+
|
52
|
+
```
|
53
|
+
JSPのコード
|
54
|
+
```
|
55
|
+
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
56
|
+
pageEncoding="UTF-8"%>
|
57
|
+
<!DOCTYPE html>
|
58
|
+
<html>
|
59
|
+
<head>
|
60
|
+
<meta charset="UTF-8">
|
61
|
+
<title>ログイン画面</title>
|
62
|
+
<link rel="stylesheet" href="CSS/style.css">
|
63
|
+
</head>
|
64
|
+
<body>
|
65
|
+
|
66
|
+
|
67
|
+
<%-- 入力フォーム --%>
|
68
|
+
<form action="manager-login-servlet" method="post">
|
69
|
+
<dl class="login-form">
|
70
|
+
<dt>ユーザID:</dt>
|
71
|
+
<dd><input type="text" size=10 name="manager_id"></dd>
|
72
|
+
<dt>パスワード:</dt>
|
73
|
+
<dd><input type="password" size=10 name="manager_password"></dd>
|
74
|
+
</dl>
|
75
|
+
<input type="submit" value="送信"><br>
|
76
|
+
</form>
|
77
|
+
|
78
|
+
<br>
|
79
|
+
|
80
|
+
</body>
|
81
|
+
</html>
|
82
|
+
```
|
19
83
|
マッピングなどは正しいです。
|
20
84
|
よろしくお願いいたします。
|