当前位置:网站首页>Servlet learning notes
Servlet learning notes
2022-04-23 20:13:00 【Jiugui wine!!!】
Catalog
Two 、 Development Servlet The of the program only needs two steps
( One ) To write servlet Class implementation Servlet Interface and its hierarchical relationship
( Two ) Write servlet Class deployment to web The server
3、 ... and 、Servlet Operating mechanism 、 working principle
One 、Servlet What is it? ?
Servlet It is a kind of operation in Web Server side Java Applications , Can produce dynamic web page , It's a kind of API Interface . meanwhile Servlet Belong to JSP The bottom of the ,Servlet It's a Java class , function JSP when , The bottom layer of the server will JSP It will compile into a Java class , This class is Servlet.
Two 、 Development Servlet The of the program only needs two steps
To achieve Servlet Interface Java The program is called Servlet
The user uses the browser to request Servlet Of url How to write ???
localhost:8080/ Project name /<url-pattern>
( One ) To write servlet Class implementation Servlet Interface and its hierarchical relationship
1、 self-written servlet Class to inherit HttpServlet class
2、 rewrite HttpServlet Of doGet() perhaps doPost() Method

( Two ) Write servlet Class deployment to web The server
1、 To configure web.xml file : First, register servlet、 The second is the setting servlet The request path for
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <!-- register servlet --> <servlet> <servlet-name>hello</servlet-name> <servlet-class>com.dai.servlet.HelloServlet</servlet-class> </servlet> <!-- Set up servlet The request path for --> <servlet-mapping> <servlet-name>hello</servlet-name> <url-pattern>/url</url-pattern> </servlet-mapping> </web-app> <!-- servlet working principle ==> url-pattern: It is equivalent to specifying a request path , When the user requests to enter Tomcat Server's webapps The project name inside servlet1 after ( Here is http://localhost:8080/servlet1) Next, add... After the path /url(http://localhost:8080/servlet1/url), You can visit the servlet 了 , Will be in web.xml Inside <servlet-mapping> seek <url-pattern> yes /url Of When you find it, you know what to do /url Of servlet The name is called hello, Then go to <servlet> Who does it match servlet Name is hello, After matching successfully , It's time to do it servlet Inside <servlet-class> Class Corresponding doGet doPost Method --><servlet></servlet> Used to declare a servlet The data of , There are mainly the following sub elements :
- <servlet-name></servlet-name> Appoint servlet The name of
- <servlet-class></servlet-class> Appoint servlet Class name of
- <servlet-mapping></servlet-mapping> Used to define servlet The corresponding URL mapping , It contains two sub elements
- <servlet-name></servlet-name> Appoint servlet The name of
- <url-pattern></url-pattern> Appoint servlet The corresponding URL
3、 ... and 、Servlet Operating mechanism 、 working principle
Operating mechanism :
servlet In a life cycle , Only one... Will be instantiated servlet object , In the 1 Create... On access , The first 2 Only run... On this visit doGet and doPost Method .
servlet It adopts multithreading mechanism , Every request , The system will allocate a thread to run doGet function
working principle :
When Web After the server receives the request from the browser , Do the following work :
版权声明
本文为[Jiugui wine!!!]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210556007147.html
边栏推荐
- 如何在BNB链上创建BEP-20通证
- SRS 的部署
- Possible root causes include a too low setting for -Xss and illegal cyclic inheritance dependencies
- Shanda Wangan shooting range experimental platform project - personal record (IV)
- Database query - course selection system
- Record: call mapper to report null pointer Foreach > the usage of not removing repetition;
- NC basic usage 1
- 山东大学软件学院项目实训-创新实训-网络安全靶场实验平台(六)
- Physical meaning of FFT: 1024 point FFT is 1024 real numbers. The actual input to FFT is 1024 complex numbers (imaginary part is 0), and the output is also 1024 complex numbers. The effective data is
- Openharmony open source developer growth plan, looking for new open source forces that change the world!
猜你喜欢

Grafana shares links with variable parameters

LeetCode动态规划训练营(1~5天)

Mysql database backup scheme

Error reported by Azkaban: Azkaban jobExecutor. utils. process. ProcessFailureException: Process exited with code 127

DTMF dual tone multi frequency signal simulation demonstration system

山东大学软件学院项目实训-创新实训-网络安全靶场实验平台(八)

基于pytorch搭建GoogleNet神经网络用于花类识别

山东大学软件学院项目实训-创新实训-网络安全靶场实验平台(五)

Shanda Wangan shooting range experimental platform project - personal record (IV)

Leetcode XOR operation
随机推荐
Cadence OrCAD capture batch change component packaging function introduction graphic tutorial and video demonstration
R language ggplot2 visual facet_wrap, and use the lineheight parameter to customize the height of the facet icon tab (gray label bar)
Understanding various team patterns in scrum patterns
nc基础用法4
[target tracking] pedestrian attitude recognition based on frame difference method combined with Kalman filter, with matlab code
R语言ggplot2可视化分面图(facet_wrap)、使用lineheight参数自定义设置分面图标签栏(灰色标签栏)的高度
PCL点云处理之计算两平面交线(五十一)
Shanda Wangan shooting range experimental platform project - personal record (IV)
selenium.common.exceptions.WebDriverException: Message: ‘chromedriver‘ executable needs to be in PAT
Speex Wiener filter and rewriting of hypergeometric distribution
Sqoop imports data from Mysql to HDFS using lzop compression format and reports NullPointerException
R language ggplot2 visualization: ggplot2 visualizes the scatter diagram and uses geom_ mark_ The ellipse function adds ellipses around data points of data clusters or data groups for annotation
R语言ggplot2可视化:ggplot2可视化散点图并使用geom_mark_ellipse函数在数据簇或数据分组的数据点周围添加椭圆进行注释
MySQL数据库 - 单表查询(二)
如何在BNB鏈上創建BEP-20通證
仓库管理数据库系统设计
CVPR 2022 | QueryDet:使用级联稀疏query加速高分辨率下的小目标检测
如何在BNB链上创建BEP-20通证
nc基础用法2
Compact CUDA tutorial - CUDA driver API

