当前位置:网站首页>JSP implicit object servlet object
JSP implicit object servlet object
2022-07-26 08:00:00 【Super Qi】
jsp Implicit objects -Servlet object
pageContent object
1. effect
You can get the current jsp All implicit objects of the page . Scope of action : Current page
2. Method


* Be careful

3. example (session object 、pageContent object 、application The difference between the three objects )
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<%
if(pageContext.getAttribute("pCount")==null){
pageContext.setAttribute("pCount",new Integer(0)); //pageContent object
}
if(session.getAttribute("sCount")==null){
session.setAttribute("sCount",new Integer(0)); //session object
}
if(application.getAttribute("aCount")==null){
application.setAttribute("aCount",new Integer(0)); //application object
}
%>
<%
Integer c1 = (Integer)pageContext.getAttribute("pCount");
pageContext.setAttribute("pCount",new Integer(c1.intValue()+1)); // In the original pageContent add 1
Integer c2 = (Integer)session.getAttribute("sCount");
session.setAttribute("sCount",new Integer(c2.intValue()+1)); // In the original pageContent add 1
Integer c3 = (Integer)application.getAttribute("aCount");
application.setAttribute("aCount",new Integer(c3.intValue()+1)); // In the original pageContent add 1
%>
<b> Page count :</b><%=pageContext.getAttribute("pCount")+"<br>" %>
<b> Session count :</b><%=session.getAttribute("sCount")+"<br>" %>
<b> Application count :</b><%=application.getAttribute("aCount")+"<br>" %>
<b> Time :</b><%=new java.sql.Time(System.currentTimeMillis()) %>
</body>
</html>
config object
1. Definition
config Objects are classes javax.servlet.ServletConfig An object of , It identifies Servlet Configuration of .
2. effect
It is mainly used to obtain the configuration information of the server , stay jsp The page passed as jsp Pass when the container is initialized
3. Method

边栏推荐
- QT listview add controls and pictures
- Come across the sea to see you
- JMeter performance test saves the results of each interface request to a file
- The difference between ArrayList and LinkedList
- The difference between throw and throws?
- Web page basic label
- DADNN: Multi-Scene CTR Prediction via Domain-Aware Deep Neural Network
- Speech at 2021 global machine learning conference
- MySQL implementation plan
- Distributed system and distributed database system (Introduction)
猜你喜欢

Excel file reading and writing (creation and parsing)

在线问题反馈模块实战(十四):实现在线答疑功能

Idea settings set shortcut keys to convert English letters to case in strings

Interview question set

The bigger the project is, the bigger it is. This is how I split it

2022-07-08 group 5 Gu Xiangquan's learning notes day01

Jmeter性能测试之将每次接口请求的结果保存到文件中

Machine learning related competition website

shardingjdbc踩坑记录

【uniapp】多种支付方式封装
随机推荐
如何关闭高位端口
Hystrix配置简单说明
MySQL implementation plan
The idea of stack simulating queue
The difference between LinkedList and ArrayList
Using producer consumer model and dpkt to process pcap files
[uniapp] encapsulation of multiple payment methods
Leetcode 206. reverse chain list (2022.07.25)
爬虫->TpImgspider
Summary of API method
Fang Wenshan, Jay Chou's best partner, will officially announce "Hualiu yuancosmos" on July 25
通用 DAO 接口设计
Brief description of hystrix configuration
QT listview add controls and pictures
Jmeter性能测试之使用存储响应内容到文件监听器
Wrong Addition
PyTorch
Matlab drawing black spots on two / three-dimensional drawings
Use of JMeter performance test to store response content to file listener
Idea settings set shortcut keys to convert English letters to case in strings