随笔 - 64  文章 - 9  trackbacks - 0
<2024年3月>
252627282912
3456789
10111213141516
17181920212223
24252627282930
31123456

常用链接

留言簿(6)

我参与的团队

随笔分类(88)

随笔档案(92)

文章分类(142)

文章档案(182)

天基成员

学习园

我的海角

搜索

  •  

积分与排名

  • 积分 - 178606
  • 排名 - 320

最新评论

<%@ page contentType="text/html;Charset=GB2312"%>
<%@ page import="java.util.*"%>
<html>
<body  bgcolor=blue and green>
<font size=8>
<% session.setMaxInactiveInterval(15);/*设置最长发呆的时间*/
   boolean boo=session.isNew();//判断session是否是一个新建的对象
   out.println("<br>如果你第一次访问当前web服务目录,你的回话是新的");
   out.println("<br>如果你不第一次访问当前web服务目录,你的回话是不新的");
   out.println("<br>会话是新吗?"+boo);
   out.println("<br>欢迎来到本页面,你的session允许的最常发呆时间"+session.getMaxInactiveInterval()+"秒");
   out.println("<br>你的session的创建时间是:"+new Date(session.getCreationTime()));
   out.println("<br>你的session的id是"+session.getId());
   Long lastTime=(Long)session.getAttribute("lastTime");/*获取索引关键字是lastTime对应的对象*/
   if(lastTime==null)
     { long n=session.getLastAccessedTime();/*获取session最后一次被操作的时间*/
       session.setAttribute("lastTime",new Long(n));/*将 Long(n)添加到session中(String key ,Object obj)*/
     }else{
     long m=session.getLastAccessedTime();
     long n=((Long)session.getAttribute("lastTime")).longValue();/*由于任何对象都可以添加到session对象中,因此取回对象时,应强制转换为原来的类型。*/
     out.println("<br>你发出的发呆时间大约是"+(m-n)+"毫秒,大约"+(m-n)/1000+"秒");
     session.setAttribute("lastTime",new Long(m));/*将new指定对象Long(m)添加到session*/
     }
%>
</font>
</body>
</html>
posted on 2009-05-05 20:47 鹏凌 阅读(152) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: