HttpSession understanding

本文介绍了如何在GlassFish服务器层级设置默认HTTP Session超时时间,包括自动创建的Session对象和其过期时间,默认为30分钟。同时,讨论了在JSP中未显式使用指令时自动创建Session的过程,并提供了在GUI界面展示Session状态的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Some web project using default HttpSession as GUI session(default timeout is 30 minutes), we can set the value at glassfish level
/cluster/home/asuser/nodes/1/domains/dve-domain/config/default-web.xml
<session-config>
<session-timeout>30</session-timeout>

just as the blog (http://javaeyetodj.iteye.com/blog/838500) said:
1  如果在jsp中没有显式使用 < %@page session="false"%>,那么jsp编译时会加上HttpSession session = HttpServletRequest.getSession(true),这就是为什么打开一个jsp页面就建立了一个session
服务端自动创建的session对象,过期时间tomcat默认是30分钟

2  servlet容器就是你所有的应用服务器(如Tomcat),服务器的主要功能就是创建和维护servlet类所需的一些实例(如 doPost(HttpServletRequest req,HttpServletResponse res)中的req和res 对象及ServletContext对象,所以当你在不同的页面会话时,就不需自己创建这些对象,只要拿到这些对象用就行了,servlet容器就创建的HttpSession对象,也就是你通过HttpSession session=res.getSession();所获取的对象。

3  在一次请求访问一个应用的时候session默认是没有的,只有遇到了 HttpServletRequest.getSession(true),这句话才建立的,所以说如果有jsp页面的话只要一访问也就有了session

if the session timeout , browser send a request with timeout session to web server,then the server will redirect to error page.

To show the session status in GUI,we can using DWR (direct web remoting) and js to fetch session. and show in GUI
To ensure the user is login,we can add the atrribute to the session, and using filter in web.xm  to filter whether the session is login.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值