+++ 202108/src/main/java/TestServlet.java
... | ... | @@ -0,0 +1,48 @@ |
1 | + | |
2 | + | |
3 | +import java.io.IOException; | |
4 | +import java.io.PrintWriter; | |
5 | + | |
6 | +import javax.servlet.ServletException; | |
7 | +import javax.servlet.annotation.WebServlet; | |
8 | +import javax.servlet.http.HttpServlet; | |
9 | +import javax.servlet.http.HttpServletRequest; | |
10 | +import javax.servlet.http.HttpServletResponse; | |
11 | + | |
12 | +/** | |
13 | + * Servlet implementation class TestServlet | |
14 | + */ | |
15 | +@WebServlet("/TestServlet") | |
16 | +public class TestServlet extends HttpServlet { | |
17 | + private static final long serialVersionUID = 1L; | |
18 | + | |
19 | + /** | |
20 | + * @see HttpServlet#HttpServlet() | |
21 | + */ | |
22 | + public TestServlet() { | |
23 | + super(); | |
24 | + // TODO Auto-generated constructor stub | |
25 | + } | |
26 | + | |
27 | + /** | |
28 | + * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) | |
29 | + */ | |
30 | + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | |
31 | + response.setContentType("text/html;charset-utf-8"); | |
32 | + PrintWriter out = response.getWriter(); | |
33 | + | |
34 | + out.println("<html>"); | |
35 | + out.println("<head><title>This is Servlet Page</title></head>"); | |
36 | + out.println("<body><h2>HelloWorld!</h2></body>"); | |
37 | + out.println("</html>"); | |
38 | + } | |
39 | + | |
40 | + /** | |
41 | + * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) | |
42 | + */ | |
43 | + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | |
44 | + // TODO Auto-generated method stub | |
45 | + doGet(request, response); | |
46 | + } | |
47 | + | |
48 | +} |
+++ 202108/src/main/webapp/0812/getpost.html
... | ... | @@ -0,0 +1,18 @@ |
1 | +<!DOCTYPE html> | |
2 | +<html> | |
3 | +<head> | |
4 | +<meta charset="UTF-8"> | |
5 | +<title>Insert title here</title> | |
6 | +</head> | |
7 | +<body> | |
8 | + <form action="getpost.jsp" method="post"> | |
9 | + <input type="text" name="text"><br><br> | |
10 | + <input type="submit" value="Send"> | |
11 | + </form> | |
12 | + <br><br> | |
13 | + <form action="getpost.jsp" method="get"> | |
14 | + <input type="text" name="text"><br><br> | |
15 | + <input type="submit" value="Send"> | |
16 | + </form> | |
17 | +</body> | |
18 | +</html>(No newline at end of file) |
+++ 202108/src/main/webapp/0812/getpost.jsp
... | ... | @@ -0,0 +1,16 @@ |
1 | +<%@ page language="java" contentType="text/html; charset=UTF-8" | |
2 | + pageEncoding="UTF-8"%> | |
3 | +<% | |
4 | + request.setCharacterEncoding("UTF-8"); //클라이언트의 인코딩 값 지정 | |
5 | + String text = request.getParameter("text"); // | |
6 | +%> | |
7 | +<!DOCTYPE html> | |
8 | +<html> | |
9 | +<head> | |
10 | +<meta charset="UTF-8"> | |
11 | +<title>Insert title here</title> | |
12 | +</head> | |
13 | +<body> | |
14 | + <%=text %> | |
15 | +</body> | |
16 | +</html>(No newline at end of file) |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?