質問編集履歴

2

質問を伏せるための質問修正であったため、復元いたしました。

2020/05/25 08:34

投稿

Aya_nishimura
Aya_nishimura

スコア16

test CHANGED
File without changes
test CHANGED
@@ -1 +1,147 @@
1
1
  以下のコードを実行すると画面遷移がうまくいきません。原因はなんでしょうか?
2
+
3
+ hoge.jps → hogeServlet → fuga.jspの順番になります。
4
+
5
+ **hoge.jsp**
6
+
7
+ ```ここに言語を入力
8
+
9
+ <%@ page language="java" contentType="text/html; charset=UTF-8"
10
+
11
+ pageEncoding="UTF-8"%>
12
+
13
+ <!DOCTYPE html>
14
+
15
+ <html>
16
+
17
+ <head>
18
+
19
+ <meta charset="UTF-8">
20
+
21
+ <title>LOGIN</title>
22
+
23
+ </head>
24
+
25
+ <body>
26
+
27
+ <form action = "HogeServlet" method = "POST">
28
+
29
+ <table>
30
+
31
+ <tr>
32
+
33
+ <td>ID</td>
34
+
35
+ <td><input type="text" name="id"></td>
36
+
37
+ </tr>
38
+
39
+ <tr>
40
+
41
+ <td>Pass</td>
42
+
43
+ <td><input type="password" name="pass"></td>
44
+
45
+ </tr>
46
+
47
+ <tr>
48
+
49
+ <td><input type = "submit" value="login"></td>
50
+
51
+ </tr>
52
+
53
+ </table>
54
+
55
+ </form>
56
+
57
+ </body>
58
+
59
+ </html>
60
+
61
+ ```
62
+
63
+ **hogeServlet**
64
+
65
+ ```ここに言語を入力
66
+
67
+ import java.io.IOException;
68
+
69
+ import javax.servlet.ServletException;
70
+
71
+ import javax.servlet.annotation.WebServlet;
72
+
73
+ import javax.servlet.http.HttpServlet;
74
+
75
+ import javax.servlet.http.HttpServletRequest;
76
+
77
+ import javax.servlet.http.HttpServletResponse;
78
+
79
+ @WebServlet("/HogeServle")
80
+
81
+ public class HogeServlet extends HttpServlet {
82
+
83
+ @Override
84
+
85
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
86
+
87
+ req.setCharacterEncoding("UTF-8");
88
+
89
+ String move = "fuga.jsp";
90
+
91
+ req.getRequestDispatcher(move).forward(req, resp);
92
+
93
+ }
94
+
95
+ }
96
+
97
+ ```
98
+
99
+ **fuga.html**
100
+
101
+ ```ここに言語を入力
102
+
103
+ <%@ page language="java" contentType="text/html; charset=UTF-8"
104
+
105
+ pageEncoding="UTF-8"%>
106
+
107
+ <!DOCTYPE html>
108
+
109
+ <html>
110
+
111
+ <head>
112
+
113
+ <meta charset="UTF-8">
114
+
115
+ <title>MENU</title>
116
+
117
+ </head>
118
+
119
+ <body>
120
+
121
+ <h1>LOGIN Success!!</h1>
122
+
123
+ <table border="1">
124
+
125
+ <tr>
126
+
127
+ <td>LOGIN USER</td>
128
+
129
+ <td>T.Yamada</td>
130
+
131
+ </tr>
132
+
133
+ <tr>
134
+
135
+ <td>LOGIN PASSWORD</td>
136
+
137
+ <td>12qwaszx</td>
138
+
139
+ </tr>
140
+
141
+ </table>
142
+
143
+ </body>
144
+
145
+ </html>
146
+
147
+ ```

1

あああああああ

2020/05/25 08:34

投稿

退会済みユーザー
test CHANGED
@@ -1 +1 @@
1
- Java開発のServletとJSPのエラーについてです。
1
+ PHP+Java開発のServletとJSPのエラーについてです。
test CHANGED
@@ -1,181 +1 @@
1
1
  以下のコードを実行すると画面遷移がうまくいきません。原因はなんでしょうか?
2
-
3
- hoge.jps → hogeServlet → fuga.jspの順番になります。
4
-
5
-
6
-
7
- **hoge.jsp**
8
-
9
- ```ここに言語を入力
10
-
11
- <%@ page language="java" contentType="text/html; charset=UTF-8"
12
-
13
- pageEncoding="UTF-8"%>
14
-
15
-
16
-
17
- <!DOCTYPE html>
18
-
19
- <html>
20
-
21
- <head>
22
-
23
- <meta charset="UTF-8">
24
-
25
- <title>LOGIN</title>
26
-
27
- </head>
28
-
29
-
30
-
31
- <body>
32
-
33
- <form action = "HogeServlet" method = "POST">
34
-
35
- <table>
36
-
37
- <tr>
38
-
39
- <td>ID</td>
40
-
41
- <td><input type="text" name="id"></td>
42
-
43
- </tr>
44
-
45
- <tr>
46
-
47
- <td>Pass</td>
48
-
49
- <td><input type="password" name="pass"></td>
50
-
51
- </tr>
52
-
53
- <tr>
54
-
55
- <td><input type = "submit" value="login"></td>
56
-
57
- </tr>
58
-
59
- </table>
60
-
61
- </form>
62
-
63
- </body>
64
-
65
- </html>
66
-
67
-
68
-
69
- ```
70
-
71
-
72
-
73
- **hogeServlet**
74
-
75
- ```ここに言語を入力
76
-
77
- import java.io.IOException;
78
-
79
-
80
-
81
- import javax.servlet.ServletException;
82
-
83
- import javax.servlet.annotation.WebServlet;
84
-
85
- import javax.servlet.http.HttpServlet;
86
-
87
- import javax.servlet.http.HttpServletRequest;
88
-
89
- import javax.servlet.http.HttpServletResponse;
90
-
91
-
92
-
93
- @WebServlet("/HogeServle")
94
-
95
-
96
-
97
- public class HogeServlet extends HttpServlet {
98
-
99
-
100
-
101
- @Override
102
-
103
- protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
104
-
105
-
106
-
107
- req.setCharacterEncoding("UTF-8");
108
-
109
-
110
-
111
- String move = "fuga.jsp";
112
-
113
-
114
-
115
- req.getRequestDispatcher(move).forward(req, resp);
116
-
117
-
118
-
119
-
120
-
121
- }
122
-
123
- }
124
-
125
-
126
-
127
- ```
128
-
129
-
130
-
131
- **fuga.html**
132
-
133
- ```ここに言語を入力
134
-
135
- <%@ page language="java" contentType="text/html; charset=UTF-8"
136
-
137
- pageEncoding="UTF-8"%>
138
-
139
- <!DOCTYPE html>
140
-
141
- <html>
142
-
143
- <head>
144
-
145
- <meta charset="UTF-8">
146
-
147
- <title>MENU</title>
148
-
149
- </head>
150
-
151
- <body>
152
-
153
- <h1>LOGIN Success!!</h1>
154
-
155
- <table border="1">
156
-
157
- <tr>
158
-
159
- <td>LOGIN USER</td>
160
-
161
- <td>T.Yamada</td>
162
-
163
- </tr>
164
-
165
- <tr>
166
-
167
- <td>LOGIN PASSWORD</td>
168
-
169
- <td>12qwaszx</td>
170
-
171
- </tr>
172
-
173
- </table>
174
-
175
- </body>
176
-
177
- </html>
178
-
179
-
180
-
181
- ```