您的当前位置:我要购书网>在线阅读>Java/J2EE/JSP

jsp教程--application 的应用

来源:互联网  作者:  发布:我要购物网收集整理  发布时间:2006-8-31 人气:379

JSP教程--Application 的应用

在前一篇里我们讲了在JSP 中使用session 来保存每个用户的私有信息,但有时服务器需要管理面向整个应用的参数,使得每个客户都能获得同样的参数值。那在JSP中应怎么办呢?和Session 一样, JSP使用Application 对象,操作的方法和Session "Times New Roman""一样。

  其API 使用如下:

  Application .setAttribute("Item", ItemValue); //设置一个应用变量

  Integer i=(Integer) Application.getAttribute("ItemName"); // 得到//item

  现以一个简单统计在线人数的的例子来说明Application的应用(这里不考虑离开的情况),init.jsp(初始化),count.jsp( 统计总人数并输出)。

init.jsp New Document <% application.setAttribute("counter",new Integer(0)); out.println(application.getAttribute("counter")); %> count.jsp New Document <% Integer i=(Integer)application.getAttribute("counter"); i=new Integer(i.intValue()+1); application.setAttribute("counter",i); out.println((Integer)application.getAttribute("counter")); %>

相关文章
· jsp教程--application 的应用
· js:关于document.execcommand()函..
· jsp中调用oracle存储过程的小例子
· jsf,为什么把简单的事情复杂化?
· jsp连接sql server 2000系统配置
· js调用web service兼谈无刷新
· js和asp 显示数据库中图片
· jsp用连接池连数据库的问题
· jscript.net 之 sqldatareader读..
· jscript错误代码及相应解释
热点文章
%>
· creating user controls
· 提高fastreplace速度 (fstrrep.pas)
· asc ii 完整码表及简介
· 自动生成拼音(汉字反查到拼音)
· sql2000无法安装的解决办法
· 浏览器集成教学 自定义浏览器
· vc++技术内幕(第四版)笔记(第7章)
· mysql5.0中文乱码解决方案
· sql server日期计算
· vc下利用ado连接access数据库
 淘宝旺旺:我要购书网上书店『图书目录
本购书中心地址: 杭州市延安路111号清波商厦南楼D座(总部) 上海市闸北区老沪太路网上购书中心(沪部),  邮编:310002
电子邮件:books@51goushu.com  经营许可证编号:沪ICP备06038574号
版权所有 2003-2008 © All Rights Reserved .购书网