Session使用
来源:互联网 发布:网络系统集成商排名 编辑:程序博客网 时间:2024/06/07 07:33
记录用户的访问次数
经典例子来说明JSP中Session的使用方法.
<%@page import="java.util.*"%>
<%
Integer loginCounter = (Integer)session.getAttribute("loginCounter");
String heading = null;
if(loginCounter == null){//若满足,则说明是第一次登陆
String heading = "Welcome,this is your First Visit";
loginCounter = new Integer(1);
}else{
loginCounter = new Integer(loginCounter.intValue() + 1);
String heading = "welcome, this is your visit#" + loginCounter;
}
session.setAttribute("loginCounter",loginCounter);//重新设这session中loginCounter值
%>
<h2><%=heading%></h2>
<p>
Infomation About Your Session<Br>
ID:<%=session.getId()%>//会话ID
CreationTime:<%=new Date(session.getCreationTime())%> //数据创建时间
time of last access:<%=new Date(session.getLastAccessdtime())%>//上次修改数据时间
loginNumber:<%=loginCounter%>
</p>
注:session中不能存储int这样的简单类型数据
session.setMaxInactiveInterval(3000)单位为秒,设置超时时间
session.getMaxInactiveInterval()获取设置的超时时间
- Session使用
- Session使用
- session是什么 & PHP使用session
- session是什么 & PHP使用session
- 什么是Session 如何使用Session
- 使用flex 的session
- hibernate Session的使用
- SESSION 的使用
- Jsp中的session使用
- Session使用的方法
- php session使用初探
- session的使用原则
- WebServic中使用Session
- ashx 使用Session
- session的使用
- Jsp中的session使用
- php5中使用session
- servlet session的使用
- 删除表空间
- tomcat内存大小设置
- HTML5中Canvas绘图方法性能测试
- android下截获动态库的函数调用
- pthread使用的例子程序以及内存泄露问题
- Session使用
- winform 导出数据到指定文件夹 excel格式 但是有重复的文件就报错
- php连接sql2005配置
- 精通Matlab与C/C++混合程序设计(第2版) pdf
- Linux下第三方库交叉编译
- vs2005中删除最近打开的项目和文件的记录
- const 的使用
- 异常的传递、重掷
- 现代IT人士到了下午上班时,眼睛一定有干涨的感觉吧!一个缓解眼疲劳的好地方