当前位置:网站首页>浅谈Servlet
浅谈Servlet
2022-07-29 05:09:00 【小洪正在努力】
什么是Servlet?
简单来说Servlet是java编写的服务器端的程序,运行在web服务器中,是不同的用户拼接动态网页的组件。
Servlet有什么作用?
- 接收用户端发来的请求
- 调用其他java程序来处理请求
- 将处理结果,返回到服务器中
Servlet怎么创建?
1、创建类继承HttpServlet
2、覆盖未实现的方法–service方法
Servlet的生命周期(重点)
我们研究Servlet的生命周期主要研究以下几点:
构造方法:
- 创建servlet对象的时候被调用。默认情况下,第一次访问这个servlet的时候调用构造方法创建对象。构造方法只被调用一次,servlet对象在tomcat是单例的。
init();方法:
- 创建完servlet对象的时候调用。只调用1次。
service();:
- 每次浏览器发出请求时候调用这个方法。可调用n次。
destory();
- 销毁servlet对象的时候调用。例如:停止服务器或者重新部署web应用时候销毁servlet对象。只调用一次。
边栏推荐
- 01-01-osg GL3 环境搭建
- Cryengine3 debugging shader method
- QML type: state state
- 365 day challenge leetcode 1000 questions - day 040 design jump table + avoid flooding + find the latest grouping with size M + color ball with reduced sales value
- AD常用快捷键
- The latest tank battle 2022 - Notes on the whole development -2
- Helm chart for Kubernetes
- MySQL的基础概念+数据库系统结构+拓展延申+基础命令学习
- 适创科技以云仿真平台,支持“中国智造”升级
- C语言函数实现输出I love you
猜你喜欢
Yangyonglin, vice president of Rushi Technology: when traditional industries encounter "digital space"
365 day challenge leetcode1000 question - distance between bus stops on day 038 + time-based key value storage + array closest to the target value after transforming the array and + maximum value at t
Best practices of JD cloud Distributed Link Tracking in financial scenarios
C语言数组入门到精通(数组精讲)
【C语言系列】—文件操作详解(上)
Webrtc audio anti weak network technology (Part 2)
Unity3D - 物体太远看不见的问题
阿里云张新涛:异构计算为数字经济提供澎湃动力
Thousands of databases, physical machines all over the country, JD logistics full volume cloud live record | interview with excellent technical team
The road to success in R & D efficiency of 1000 person Internet companies
随机推荐
CMake 设置vs启动运行环境路径
Unity3D - 物体太远看不见的问题
365天挑战LeetCode1000题——Day 036 二叉树剪枝 + 子数组和排序后的区间和 + 删除最短的子数组使剩余数组有序
167. 两数之和 II - 输入有序数组
京东云联合Forrester咨询发布混合云报告 云原生成为驱动产业发展新引擎
MySQL的详细安装使用教程(保姆式安装图文讲解)
英伟达周锡健:设计到数字营销的最后一公里
EXIT中断详解
365 day challenge leetcode 1000 questions - day 037 elements and the maximum side length of squares less than or equal to the threshold + the number of subsequences that meet the conditions
365 day challenge leetcode 1000 questions - day 041 two point search completion anniversary + nth magic number + online election
365天挑战LeetCode1000题——Day 035 每日一题 + 二分查找 13
最新坦克大战2022-全程开发笔记-1
直播预告|如何节省30%人工成本,缩短80%商标办理周期?
串口通讯部分详解
CMU15-213 Shell Lab实验记录
C language one-dimensional array
AD常用快捷键
Helm chart for Kubernetes
数千个数据库、遍布全国的物理机,京东物流全量上云实录 | 卓越技术团队访谈录
200 多家 ISV 入驻!阿里云计算巢发布一周年