当前位置:网站首页>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
边栏推荐
- SIGIR'22 "Microsoft" CTR estimation: using context information to promote feature representation learning
- Speex Wiener filter and rewriting of hypergeometric distribution
- Cadence Orcad Capture 批量更改元件封装功能介绍图文教程及视频演示
- 仓库管理数据库系统设计
- [target tracking] pedestrian attitude recognition based on frame difference method combined with Kalman filter, with matlab code
- Mysql database - single table query (I)
- Efficient serial port cyclic buffer receiving processing idea and code 2
- nc基础用法2
- MySQL数据库 - 单表查询(二)
- Introduction to electron tutorial 3 - process communication
猜你喜欢

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

波场DAO新物种下场,USDD如何破局稳定币市场?

Notes of Tang Shu's grammar class in postgraduate entrance examination English

Unity general steps for creating a hyper realistic 3D scene

【数值预测案例】(3) LSTM 时间序列电量预测,附Tensorflow完整代码
![[target tracking] pedestrian attitude recognition based on frame difference method combined with Kalman filter, with matlab code](/img/30/39de1628cb47f715056fb898955ff5.png)
[target tracking] pedestrian attitude recognition based on frame difference method combined with Kalman filter, with matlab code

如何在BNB链上创建BEP-20通证

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

SIGIR'22「微软」CTR估计:利用上下文信息促进特征表征学习

Software College of Shandong University Project Training - Innovation Training - network security shooting range experimental platform (8)
随机推荐
考研英语唐叔的语法课笔记
微信中金财富高端专区安全吗,证券如何开户呢
Mysql database - single table query (III)
R language uses econocrats package to create microeconomic or macroeconomic map, visualize indifference function indifference curve, customize calculation intersection, and customize the parameters of
nc基础用法
Design of warehouse management database system
Wave field Dao new species end up, how does usdd break the situation and stabilize the currency market?
使用 WPAD/PAC 和 JScript在win11中进行远程代码执行1
filebeat、logstash配置安装
R language survival package coxph function to build Cox regression model, ggrisk package ggrisk function and two_ Scatter function visualizes the risk score map of Cox regression, interprets the risk
NC basic usage 1
Is the wechat CICC wealth high-end zone safe? How to open an account for securities
PCL点云处理之直线与平面的交点计算(五十三)
Building googlenet neural network based on pytorch for flower recognition
中金财富公司怎么样,开户安全吗
Kubernetes getting started to proficient - install openelb on kubernetes
Electron入门教程3 ——进程通信
How to create bep-20 pass on BNB chain
【2022】将3D目标检测看作序列预测-Point2Seq: Detecting 3D Objects as Sequences
山东大学软件学院项目实训-创新实训-网络安全靶场实验平台(七)

