当前位置:网站首页>jsp九大内置对象
jsp九大内置对象
2022-07-25 21:50:00 【华为云】
jsp九大内置对象
jsp九大内置对象,是指Tomcat在翻译jsp页面成为Servlet源代码后,内部提供的九大对象,叫内置对象。
request 请求对象
response 响应对象
pageContext jsp的上下文对象
session 会话对象
application ServletContext对象
config ServletConfig对象
exception 异常对象
out jsp输出流对象
jsp四大域对象
域对象是可以向Map一样存取数据的对象。四个域对象功能一样,他们对数据的存取范围不同
四个域对象分别是:
| 域对象 | 所属类 | 访问范围 |
| pageContext | (PageContextImpl类) | 当前jsp页面范围内有效 |
| request | (HttpServletRequest类) | 一次请求内有效 |
| session | (HttpSession类) | 一个会话范围内有效(打开浏览器访问服务器,直到关闭浏览器) |
| application | (ServletContext类) | 整个web工程范围内都有效(只要web工程不停止,数据都在) |
//往四个域都分别保存了数据
<%
pageContext.setAttribute("key","pageContext");
request.setAttribute("key","request");
session.setAttribute("key","session");
application.setAttribute("key","application");
%>
pageContext域是否有值:<%=pageContext.getAttribute("key")%> <br>
request域是否有值:<%=pageContext.getAttribute("key")%> <br>
session域是否有值:<%=session.getAttribute("key")%> <br>
application域是否有值:<%=application.getAttribute("key")%> <br>
创建另一个jsp页面:
其他范围测试:
他们的范围是从小到大的,使用时一般先使用小范围,小范围不够用再使用范围。(内存优化的原因)
| 小:pageContext |
| request |
| session |
| 大:application |
jsp中的out输出和response.getWriter输出的区别
我们可以发现,无论谁在前输出的结果,都是response的在前
图示分析:
当jsp页面中的所有代码执行完之后会做的操作:
1、执行out.flush()操作,会把out缓冲区的数据追加写入到response缓冲区末端。
2、会执行response的刷新操作,会把数据写给客户端。
验证:
由于jsp翻译之后,底层源代码都是使用out来进行输出,所以一般情况下,我们在jsp页面统一使用out进行输出。避免打乱页面输出的顺序。
out.print()和out.write()
out.write()输出字符串字符串没问题
out.print()可以输出任意数据(都会转化成字符串后调用write输出)
结论:在jsp页面中,可以统一使用呢out.print()来进行输出
边栏推荐
- 新版Maixhub部署(V831与K210)
- 2022 love analysis ― bank digitalization practice report
- Unity Metaverse(二)、Mixamo & Animator 混合树与动画融合
- Create EDA - why should I learn EDA
- [redis underlying parsing] string type
- Fastjson deserialization vulnerability utilization analysis collection
- Simple use of protobuf
- Come again
- Excuse me, how to deal with repeated consumption of MySQL data
- Guys, how can Flink SQL submit tasks in per job mode?
猜你喜欢
QT | learn about QT creator by creating a simple project

Jmeter--- set proxy recording request
![[interview: concurrent Article 23: multithreading: Join] re understanding of join](/img/ee/5160a55e776336ba844abe8e9db72a.png)
[interview: concurrent Article 23: multithreading: Join] re understanding of join

分享|智慧消防应急管理平台解决方案(附PDF)

919. 完全二叉树插入器 : 简单 BFS 运用题

ansible+Crontab批部署巡检

ag 搜索工具参数详解

How to implement distributed locks with redis?

Detailed explanation of JVM memory model and structure (five model diagrams)

GPON介绍及华为OLT网关注册配置流程
随机推荐
[ManageEngine] value brought by Siem to enterprises
redis主从架构锁失效问题(主从)
How to choose sentinel vs. hystrix current limiting?
The noise reduction effect is increased by more than 6 times! With the microphone inside the headset, this wireless noise reduction headset is unusual!
C语言游戏 双缓存解决闪屏问题 详细总结[通俗易懂]
How to configure and use rocksdb in the flinksql environment
[MAIXPY]kpu: load error:2005, ERR_READ_FILE: read file failed问题解决
How to evaluate hardware resources (number of CPUs, memory size) when Oracle migrates from small computers to x86 architecture? Is there a measurement index or company?
I/O案例实操
【饭谈】细说:下克上,向上管理,向上画饼。
【饭谈】测试平台为什么有组件化?模块化?很多看不到的地方设计的很好是种浪费么?
CNN structural design skills: taking into account speed accuracy and engineering implementation
MPI学习笔记(二):矩阵相乘的两种实现方法
Dear bosses, how can I print the result of Flink SQL to the console and display it completely?
再次来光顾
ag 搜索工具参数详解
【饭谈】那些看似为公司着想,实际却让人无法理解的事(二:面试时的软素质“眼缘”)
Configuration and use of multithreading
zigbee开发板(nxpzigbee开发)
【面试:并发篇24:多线程:综合练习】顺序控制








