Skip to content

Commit 9c3d9cd

Browse files
author
cicadasmile
committed
JavaEE基础(03):Http请求详解,握手挥手流程简介
1 parent 8c00082 commit 9c3d9cd

File tree

6 files changed

+129
-0
lines changed

6 files changed

+129
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
[JavaEE基础(01):Servlet实现方式,生命周期执行过程](https://mp.weixin.qq.com/s?__biz=MzU4Njg0MzYwNw==&mid=2247484304&idx=1&sn=dd6b6852e35031dd07f70d441f3ddc85&chksm=fdf45728ca83de3e158597030cf46b1677eccf533f9e1412690cd64b0ec0cce544711ceabddb&token=1248678182&lang=zh_CN#rd)<br/>
44
[JavaEE基础(02):Servlet核心API用法详解](https://mp.weixin.qq.com/s?__biz=MzU4Njg0MzYwNw==&mid=2247484309&idx=1&sn=fc8237aef2f246f85b978561f4b37e1e&chksm=fdf4572dca83de3b8affdf4a9a8c8b3c18e4c5203c3e663e0bfaeb53788d3e2d26fa829bb8c6&token=1248678182&lang=zh_CN#rd)<br/>
5+
[JavaEE基础(03):Http请求详解,握手挥手流程简介](https://mp.weixin.qq.com/s?__biz=MzU4Njg0MzYwNw==&mid=2247484318&idx=1&sn=125780e20ada2f3d1451a1563a1c1e6f&chksm=fdf45726ca83de30adc5956a16d16151825b37c0adf5350214899ade39fef47f17ee35b2390d&token=1248678182&lang=zh_CN#rd)<br/>
56

67
持续更新中...
78

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>java-ee-base-parent</artifactId>
7+
<groupId>com.java.ee.parent</groupId>
8+
<version>1.0-SNAPSHOT</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
<groupId>com.node03.servlet</groupId>
12+
<artifactId>node03-servlet-http</artifactId>
13+
<packaging>war</packaging>
14+
15+
<properties>
16+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
17+
<maven.compiler.source>1.8</maven.compiler.source>
18+
<maven.compiler.target>1.8</maven.compiler.target>
19+
<jstl.version>1.2</jstl.version>
20+
<servlet-api.version>2.5</servlet-api.version>
21+
<jsp-api.version>2.0</jsp-api.version>
22+
</properties>
23+
24+
<dependencies>
25+
<!-- JSP相关 依赖包-->
26+
<dependency>
27+
<groupId>jstl</groupId>
28+
<artifactId>jstl</artifactId>
29+
<version>${jstl.version}</version>
30+
</dependency>
31+
<dependency>
32+
<groupId>javax.servlet</groupId>
33+
<artifactId>jsp-api</artifactId>
34+
<version>${jsp-api.version}</version>
35+
<scope>provided</scope>
36+
</dependency>
37+
<!-- servlet依赖包 -->
38+
<dependency>
39+
<groupId>javax.servlet</groupId>
40+
<artifactId>servlet-api</artifactId>
41+
<version>${servlet-api.version}</version>
42+
<scope>provided</scope>
43+
</dependency>
44+
<dependency>
45+
<groupId>junit</groupId>
46+
<artifactId>junit</artifactId>
47+
<version>4.12</version>
48+
</dependency>
49+
</dependencies>
50+
51+
</project>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.node03.servlet.impl;
2+
3+
import javax.servlet.ServletException;
4+
import javax.servlet.http.HttpServlet;
5+
import javax.servlet.http.HttpServletRequest;
6+
import javax.servlet.http.HttpServletResponse;
7+
import java.io.IOException;
8+
9+
public class ServletOneImpl extends HttpServlet {
10+
@Override
11+
protected void doGet(HttpServletRequest request, HttpServletResponse response)
12+
throws ServletException, IOException {
13+
System.out.println("doGet...");
14+
response.setContentType("text/html;charset=utf-8");
15+
String userName = request.getParameter("userName") ;
16+
response.getWriter().print("Hello:"+userName);
17+
}
18+
19+
@Override
20+
protected void doPost(HttpServletRequest request, HttpServletResponse response)
21+
throws ServletException, IOException {
22+
System.out.println("doPost...");
23+
response.setContentType("text/html;charset=utf-8");
24+
String userName = request.getParameter("userName") ;
25+
response.getWriter().print("Hello:"+userName);
26+
}
27+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns="http://java.sun.com/xml/ns/javaee"
5+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
6+
id="WebApp_ID" version="3.0">
7+
8+
<display-name>cicada_servlet</display-name>
9+
<context-param>
10+
<param-name>encoding</param-name>
11+
<param-value>UTF-8</param-value>
12+
</context-param>
13+
14+
<servlet>
15+
<servlet-name>servletOneImpl</servlet-name>
16+
<servlet-class>com.node03.servlet.impl.ServletOneImpl</servlet-class>
17+
</servlet>
18+
<servlet-mapping>
19+
<servlet-name>servletOneImpl</servlet-name>
20+
<url-pattern>/servletOneImpl</url-pattern>
21+
</servlet-mapping>
22+
23+
</web-app>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<html>
2+
<body>
3+
<hr/>
4+
<h2>Http</h2>
5+
<hr/>
6+
</body>
7+
</html>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<html>
2+
<head>
3+
<title>index.html</title>
4+
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
5+
</head>
6+
<body>
7+
<hr/>
8+
<h2>GET REQUEST</h2>
9+
<form method="GET" action="/servletOneImpl">
10+
userName:<input type="text" name="userName"/>
11+
<input type="submit" value="SUBMIT"/>
12+
</form>
13+
<hr/>
14+
<h2>POST REQUEST</h2>
15+
<form method="POST" action="/servletOneImpl">
16+
userName:<input type="text" name="userName"/>
17+
<input type="submit" value="SUBMIT"/>
18+
</form>
19+
</body>
20+
</html>

0 commit comments

Comments
 (0)