当前位置:网站首页>Life cycle of Servlet
Life cycle of Servlet
2022-07-03 08:38:00 【The corner of fufu】
Catalog
Servlet Life cycle
1、 load -web.xml
<!-- Statement Servlet -->
<servlet>
<!-- servlet Another name for -->
<servlet-name>first</servlet-name>
<!-- Sensitive information , Need alias -->
<servlet-class>com.imooc.servlet.FirstServlet</servlet-class>
</servlet>
<!-- take Servlet And URL binding -->
<servlet-mapping>
<servlet-name>first</servlet-name>
<url-pattern>/hi</url-pattern>
</servlet-mapping>
load web.xml Will not create FirstServlet object 
2、 establish - Constructors
public FirstServlet() {
System.out.println(" Creating FirstServlet object ");
}
3、 initialization -init()
public void init(ServletConfig config) throws ServletException {
System.out.println(" Initializing FirstServlet object ");
}
4、 Provide services -service()
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
// Receive the parameters sent by the request
String name = request.getParameter("name");
String html = "<h1 style='color:red'>hi," + name + "!</h1><hr/>";
System.out.println(" The response data returned to the browser is :" + html);
PrintWriter out = response.getWriter();
out.println(html);// take html Send it back to the browser
}
- On a visit service() Method FirstServlet object


- Multiple access , There is only one in the global FirstServlet object

5、 The destruction -destory()
public void destroy() {
System.out.println(" It's being destroyed FirstServlet object ");
}
- The code will be destroyed after adjustment FirstServlet object , Only when you visit again FirstServlet object

边栏推荐
- [rust notes] 05 error handling
- Detailed explanation of all transfer function (activation function) formulas of MATLAB neural network
- Graphics_ Games101/202 learning notes
- Osgearth starry background
- 分配异常的servlet
- Unity editor expansion - controls, layouts
- [rust notes] 07 structure
- [RPC] RPC remote procedure call
- Simply start with the essence and principle of SOM neural network
- 【更新中】微信小程序学习笔记_3
猜你喜欢

Advanced OSG collision detection

Base64和Base64URL

图像处理8-CNN图像分类

Un système de gestion de centre commercial pour la conception de cours de technologie d'application de base de données

Simply start with the essence and principle of SOM neural network

梯度下降法求解BP神经网络的简单Demo

Monotonic stack -503 Next bigger Element II

请求参数的发送和接收

Graphics_ Learnopongl learning notes

matlab神经网络所有传递函数(激活函数)公式详解
随机推荐
Osgearth north arrow display
【K&R】中文第二版 个人题解 Chapter1
【音视频】ijkplayer错误码
[rust notes] 11 practical features
Delete the last character of the string in golang
Redis data structure
Unity Editor Extension - Outline
【Rust 笔记】11-实用特型
C course design employee information management system
[public key cryptography] ECC elliptic cryptosystem (implementing ElGamal encryption method)
[rust notes] 07 structure
单调栈-503. 下一个更大元素 II
Exe file running window embedding QT window
[concurrent programming] working mechanism and type of thread pool
Conversion between golang JSON format and structure
梯度下降法求解BP神经网络的简单Demo
注解简化配置与启动时加载
Notes on understanding applets 2022/7/3
22-06-27 西安 redis(01) 安装redis、redis5种常见数据类型的命令
Go resolve ID card