当前位置:网站首页>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
边栏推荐
- Base64和Base64URL
- Osgearth starry background
- Development material set
- Monotonic stack -503 Next bigger Element II
- Chocolate installation
- Solution détaillée de toutes les formules de fonction de transfert (fonction d'activation) du réseau neuronal MATLAB
- Message queue for interprocess communication
- [concurrent programming] working mechanism and type of thread pool
- 注解简化配置与启动时加载
- Thymeleaf 404 reports an error: there was unexpected error (type=not found, status=404)
猜你喜欢
XPath实现XML文档的查询
注解简化配置与启动时加载
P1596 [USACO10OCT]Lake Counting S
Graphics_ Learnopongl learning notes
matlab神經網絡所有傳遞函數(激活函數)公式詳解
KunlunBase MeetUP 等您来!
[concurrent programming] concurrent tool class of thread
Jupyter remote server configuration and server startup
Creation of osgearth earth files to the earth ------ osgearth rendering engine series (1)
Introduction to hexadecimal coding
随机推荐
producer consumer problem
【Rust 笔记】07-结构体
【Rust笔记】05-错误处理
Jupyter remote server configuration and server startup
Sequence of map implementation classes
Osgearth topographic shading map drawing
Mysql容器化(1)Docker安装MySQL
Osgconv tool usage
C course design employee information management system
Solution détaillée de toutes les formules de fonction de transfert (fonction d'activation) du réseau neuronal MATLAB
Swagger document configuration
Unity Editor Extension - drag and drop
Detailed explanation of all transfer function (activation function) formulas of MATLAB neural network
[concurrent programming] Table hopping and blocking queue
Map的实现类的顺序性
单调栈-503. 下一个更大元素 II
Mall management system of database application technology course design
How to deal with the core task delay caused by insufficient data warehouse resources
VIM learning notes from introduction to silk skating
[cloud native] introduction and use of feign of microservices