当前位置:网站首页>JSP nine built-in objects
JSP nine built-in objects
2022-07-25 22:00:00 【Hua Weiyun】
jsp Nine built-in objects
jsp Nine built-in objects , Refer to Tomcat In Translation jsp The page becomes Servlet After the source code , Nine internal objects , It's called built-in objects .
request Request object
response The response object
pageContext jsp Context object
session Conversation object
application ServletContext object
config ServletConfig object
exception Exception object
out jsp Output stream object
jsp Four domain objects
Domain objects can be Map The same object that accesses data . The four domain objects function the same , They have different access ranges to data
The four domain objects are :
| Domain object | Category | Scope of visit |
| pageContext | (PageContextImpl class ) | At present jsp Valid within page range |
| request | (HttpServletRequest class ) | Valid within one request |
| session | (HttpSession class ) | Valid within a session scope ( Open the browser to access the server , Until the browser is closed ) |
| application | (ServletContext class ) | Whole web Valid within the scope of work ( as long as web The project doesn't stop , The data are all there ) |
// Data is saved to each of the four fields
<%
pageContext.setAttribute("key","pageContext");
request.setAttribute("key","request");
session.setAttribute("key","session");
application.setAttribute("key","application");
%>
pageContext Whether the field has a value :<%=pageContext.getAttribute("key")%> <br>
request Whether the field has a value :<%=pageContext.getAttribute("key")%> <br>
session Whether the field has a value :<%=session.getAttribute("key")%> <br>
application Whether the field has a value :<%=application.getAttribute("key")%> <br>
Create another jsp page :
Other scope tests :
They range from small to large , When using, generally use a small range first , Small range is not enough for reuse .( Reasons for memory optimization )
| Small :pageContext |
| request |
| session |
| Big :application |
jsp Medium out Output and response.getWriter The difference in output
We can find out , Whoever outputs the results before , All are response First
Graphic analysis :
When jsp On the page All code execution completed What will be done later :
1、 perform out.flush() operation , Will be able to out The data of the buffer is appended to the response End of buffer .
2、 Will execute response Refresh operation of , Write data to the client .
verification :
because jsp After translation , The underlying source code uses out To output , So in general , We are jsp Unified use of pages out For the output . Avoid disrupting the order of page output .
out.print() and out.write()
out.write() The output string is OK
out.print() Any data can be output ( Will be converted to a string after calling write Output )
Conclusion : stay jsp On the page , Can it be used uniformly out.print() To output
边栏推荐
猜你喜欢

GPON介绍及华为OLT网关注册配置流程
![[leetcode ladder] linked list · 021 merge two ordered linked lists](/img/72/d3e46a820796a48b458cd2d0a18f8f.png)
[leetcode ladder] linked list · 021 merge two ordered linked lists

2 lines of code to generate a solid desktop background
![[dinner talk] those things that seem to be for the sake of the company but are actually incomprehensible (2: soft quality](/img/11/42c4674d23ee93850fb3d2de0d0932.png)
[dinner talk] those things that seem to be for the sake of the company but are actually incomprehensible (2: soft quality "eye edge" during interview)
![[assembly language 01] basic knowledge](/img/df/d586288b8f41211141bc4e2bca20cf.png)
[assembly language 01] basic knowledge

8000 word super detailed custom structure type

The second short contact of gamecloud 1608

2年功能测试,却感觉自己什么都不会,2022我该何去何从?

GPON introduction and Huawei OLT gateway registration and configuration process

New maixhub deployment (v831 and k210)
随机推荐
GPON介绍及华为OLT网关注册配置流程
Basic knowledge in the project
Pyg tutorial (8): calculate a more efficient sparse matrix form
Acwing 866. determining prime numbers by trial division
The reisson distributed lock renewal failed due to network reasons, resulting in the automatic release of the lock when the business is still executing but the lock is not renewed.
[redis underlying parsing] string type
ZigBee development board (nxpzigbee Development)
jsp九大内置对象
Jmeter--- set proxy recording request
Redis 使用详解
【饭谈】如何设计好一款测试平台?
Three ways to allocate disk space
JMeter websocket interface test
Ansible+cronab batch deployment patrol
Performance debugging -- chrome performance
How to implement distributed locks with redis?
成为比开发硬气的测试人,我都经历了什么?
JMeter websocket接口测试
6-18漏洞利用-后门连接
2022 love analysis ― bank digitalization practice report








