国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JSP > 正文

JSP教程--Application 的應(yīng)用

2024-09-05 00:19:26
字體:
供稿:網(wǎng)友

jsp教程--application 的應(yīng)用

    在前一篇里我們講了在jsp 中使用session 來保存每個(gè)用戶的私有信息,但有時(shí)服務(wù)器需要管理面向整個(gè)應(yīng)用的參數(shù),使得每個(gè)客戶都能獲得同樣的參數(shù)值。那在jsp中應(yīng)怎么辦呢?和session 一樣, jsp使用application 對(duì)象,操作的方法和session "times new roman""一樣。

  其api 使用如下:

  application .setattribute("item", itemvalue); //設(shè)置一個(gè)應(yīng)用變量

  integer i=(integer) application.getattribute("itemname"); // 得到//item

  現(xiàn)以一個(gè)簡(jiǎn)單統(tǒng)計(jì)在線人數(shù)的的例子來說明application的應(yīng)用(這里不考慮離開的情況),init.jsp(初始化),count.jsp( 統(tǒng)計(jì)總?cè)藬?shù)并輸出)。

init.jsp
<html>
<head>
<title> new document </title>
<body bgcolor="#ffffff">
<%
application.setattribute("counter",new integer(0));
out.println(application.getattribute("counter"));
%>
</body>
</html>
count.jsp
<html>
<head>
<title> new document </title>
</head>
<body bgcolor="#ffffff">
<%
integer i=(integer)application.getattribute("counter");
i=new integer(i.intvalue()+1);
application.setattribute("counter",i);
out.println((integer)application.getattribute("counter"));
%>
</body>
</html>


 

上一篇:JSP標(biāo)簽庫介紹

下一篇:JSP內(nèi)幕

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 乐清市| 台北县| 平湖市| 通道| 大同县| 华安县| 仙游县| 洪江市| 广德县| 兰溪市| 台中市| 商丘市| 洪洞县| 汉川市| 罗江县| 新平| 扬中市| 奉贤区| 东方市| 榆中县| 平泉县| 静乐县| 凌海市| 乌审旗| 拜泉县| 洪泽县| 内丘县| 双柏县| 衡阳市| 金门县| 同仁县| 沈丘县| 吉林省| 抚宁县| 武陟县| 双流县| 肃北| 两当县| 民和| 达拉特旗| 宜城市|