-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServlet_Hello.java
More file actions
100 lines (75 loc) · 1.83 KB
/
Servlet_Hello.java
File metadata and controls
100 lines (75 loc) · 1.83 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
/*
* Servlet实现之第一种方式实现Servlet
*/
package com.bj.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
public class Servlet_Hello implements Servlet{
/**
* Method init
*
*
* @param parm1
*
@throws ServletException
*
*/
public void init(ServletConfig parm1) throws ServletException {
// TODO: Add your code here
System.out.println("init it");
}
/**
* Method getServletConfig
*
*
* @return
*
*/
public ServletConfig getServletConfig() {
// TODO: Add your code here
return null;
}
/**
* Method service
*
*用于处理业务逻辑,把业务逻辑代码写在这里,当用户访问每一次都会调用该方法
* @param parm1
* @param parm2
*parm1用于获取客户端信息,param2用于向客户端返回信息
@throws ServletException
@throws IOException
*
*/
public void service(ServletRequest parm1, ServletResponse parm2) throws ServletException, IOException {
// TODO: Add your code here
System.out.println("service it");
//param1中得到PrintWriter
PrintWriter pw=parm2.getWriter();
pw.println("hello world");
}
/**
* Method getServletInfo
*
*
* @return
*
*/
public String getServletInfo() {
// TODO: Add your code here
return "";
}
/**
* Method destroy
*1、关闭tomcat;2、reload tomcat服务器3、关机
*
*/
public void destroy() {
// TODO: Add your code here
System.out.println("destroy!");
}
}