其他页面中的会话 [英] Sessions in other pages

查看:74
本文介绍了其他页面中的会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将会话放入其他页面? (jsp,servlet,java使用DAO)。在jsp页面中,我使用组合框转到其他页面。是否有可能在这些页面中放置会话或有任何想法吗?



先谢谢你们!

How to put sessions in other pages? (jsp,servlet,java using DAO).In jsp pages i used combo boxes to go to other pages. is it possible to put sessions in that pages or are there any ideas for this?

Thank you in advanced!

推荐答案

会话不属于页面,似乎你已经将你的scoop设置为请求(请求scoop用于页面调用)



只需跟踪你的会话与 request.getSession()例如

在第1页:

Session are not belong to pages, it seems you have set your scoop as request (request scoop is for a page invocation)

simply track your session with request.getSession() for example
in page 1:
<![CDATA[<%
  request.getSession().setAttribute("name","value");
%>]]>





然后获取第2页的会话值



and then get the session values in page 2

<![CDATA[<%
 String name=(String) request.getSession().getAttribute("name");
%>]]>





默认会话超时为30分钟,您可以延长它,但是因为有长时间数据,改为使用cookies



the default session timeout is 30 min while you can extend it, but for having long time data, use cookies instead


这篇关于其他页面中的会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆