当前位置:网站首页>Summary of request and response and their ServletContext
Summary of request and response and their ServletContext
2022-04-23 13:11:00 【ArchieSean】
The blogger's name is taken from 《 Shaun the Sheep 》 Shawn the lamb in the , The name is : Sean , Transliterated as Sean, Take your own last name : Archie , In order to conform to our reading habits , Connected to form ArchieSean. The blogger is currently a junior reading , Aiming to build blog into a technical stack of personal online notes , Be convenient for yourself and others . If there are any mistakes in the blog , Please point out , Thank you. .
List of articles
Request and Response
principle
- request and response Are objects provided by the server .
- request Is used to get the request message
- response Is used to set the response message .
Request
Request Architecture of

Another class is provided by the server , It has achieved HttpServletRequest Interface .
Request The function of
More commonly used are :
- A common way to get request parameters
request.getParameter(String name);
request. getParameterValues(String name);
request.getParameterNames();
request. getParameterMap();
- solve POST Ask for Chinese code
request.setCharacterEncoding("utf-8");
- forward
request.getRequestDispatcher(String path).forward(request,response);
- Use of shared data
request.setAttribute(String key,Object obj);
request.getAttribute(String key);
request.removeAttribute(String key);
- obtain ServletContext object
request.getServletContext();
Response
Response Architecture

Same as Request equally , Provides a server class , Realized HttpServletResponse Interface .
Response The function of
Commonly used :
- Solve the problem of Chinese garbled code
resp.setContentType("MIME type ; Character set ");
- Get stream object
- Get character output stream
- Get byte output stream
- Redirect
resp.sendRedirect(String path);
ServletContext
summary
Simply speaking ,ServletContext yes web The largest domain object in the application . It means that all users under the same server can share data .
obtain
There are two ways to get this object :
- adopt request To get
request.getServletContext();
- adopt servlet To get
this.getServletContext();
function
- Data sharing ( Three general methods of domain objects )
- obtain MIME type
getMimeType(String file);
- Get resource path
getRealPath(String path);
If there are any questions in the blog , Please leave a message .
版权声明
本文为[ArchieSean]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231306322713.html
边栏推荐
- Imx6ull QEMU bare metal tutorial 1: GPIO, iomux, I2C
- Golang implements a five insurance and one gold calculator with web interface
- MySQL -- 16. Data structure of index
- decast id.var measure. Var data splitting and merging
- Async void caused the program to crash
- Common interview questions and detailed analysis of the latest Android developers in 2020
- 内核错误: No rule to make target ‘debian/canonical-certs.pem‘, needed by ‘certs/x509_certificate_list‘
- 4.22学习记录(你一天只做了水题是吗)
- AUTOSAR from introduction to mastery 100 lectures (86) - 2F of UDS service foundation
- SSM整合之pom.xml
猜你喜欢

2020最新Android大厂高频面试题解析大全(BAT TMD JD 小米)

web三大组件之Servlet

R语言中dcast 和 melt的使用 简单易懂

超40W奖金池等你来战!第二届“长沙银行杯”腾讯云启创新大赛火热来袭!
![[untitled] make a 0-99 counter, P1 7 connected to key, P2 connected to nixie tube section, common anode nixie tube, P3 0,P3. 1. Connect the nixie tube bit code. Each time you press the key, the nixie](/img/d1/b0ec21419db0cd3641f5fae8458c50.png)
[untitled] make a 0-99 counter, P1 7 connected to key, P2 connected to nixie tube section, common anode nixie tube, P3 0,P3. 1. Connect the nixie tube bit code. Each time you press the key, the nixie

Summary of JVM knowledge points - continuously updated

vscode小技巧

The difference between string and character array in C language

The first lesson is canvas, showing a small case

榜样专访 | 孙光浩:高校俱乐部伴我成长并创业
随机推荐
CSDN高校俱乐部“名师高校行”——湖南师范大学站
超40W奖金池等你来战!第二届“长沙银行杯”腾讯云启创新大赛火热来袭!
4.22学习记录(你一天只做了水题是吗)
SPI NAND flash summary
(personal) sorting out system vulnerabilities after recent project development
nodeJs + websocket 循环小案例
filter()遍历Array异常友好
The use of dcast and melt in R language is simple and easy to understand
2020年最新字节跳动Android开发者常见面试题及详细解析
The filter() traverses the array, which is extremely friendly
Proteus 8.10 installation problem (personal test is stable and does not flash back!)
Brief introduction of asynchronous encapsulation interface request based on uniapp
MySQL -- 16. Data structure of index
Mui wechat payment pit
Customize classloader and implement hot deployment - use loadclass
Nodejs + Mysql realize simple registration function (small demo)
SSM整合之pom.xml
ECDSA signature verification principle and C language implementation
Byte jump 2020 autumn recruitment programming question: quickly find your own ranking according to the job number
Read the data in Presto through sparksql and save it to Clickhouse