JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » Application Server » Tomcat  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友   
reply to topicthreaded modego to previous topicgo to next topic
本主題所含的標籤
無標籤
作者 TOMCAT怎么配置SESSION 失效时间? [精華]
Kaede





發文: 15
積分: 0
於 2004-08-11 00:15 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
TOMCAT怎么配置SESSION 失效时间?
谢谢!!!!


reply to postreply to post
作者 Re:TOMCAT怎么配置SESSION 失效时间? [Re:Kaede]
browser

戀香

版主

發文: 3570
積分: 1
於 2004-08-11 02:35 user profilesend a private message to usersend email to browserreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Kaede wrote:
TOMCAT怎么配置SESSION 失效时间?
谢谢!!!!


這種事情設定在 web.xml 即可

1
2
3
<session-config>
   <sessioin-timeout>30</sessioin-timeout>
</session-config>


單位為 分鐘


reply to postreply to post
作者 Re:TOMCAT怎么配置SESSION 失效时间? [Re:Kaede]
x3711699





發文: 148
積分: 4
於 2004-08-12 08:05 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
那請問是否有"永遠"的設定?
是改成-1嗎?

純好奇問


x3711699 edited on 2004-08-12 08:08
reply to postreply to post
作者 Re:TOMCAT怎么配置SESSION 失效???}? [Re:x3711699]
frank



版主

發文: 498
積分: 13
於 2004-08-12 09:08 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
x3711699 wrote:
那請問是否有"永遠"的設定?
是改成-1嗎?

在 web.xml 宣告之 DTD http://java.sun.com/dtd/web-app_2_3.dtd
1
2
3
4
5
6
7
8
9
10
<!--
The session-timeout element defines the default session timeout
interval for all sessions created in this web application. The
specified timeout must be expressed in a whole number of minutes.
If the timeout is 0 or less, the container ensures the default
behaviour of sessions is never to time out.
 
Used in: session-config
-->
<!ELEMENT session-timeout (#PCDATA)>

所以,只要設 0 或 負值,則表 session 不會 timeout;
這裡的 never 應指該 application scope 內,所有產生的 session 不會被 sessionDestroyed。

另外,在 More Servlets and JavaServer Pages
chapter 5 Controlling Web Application Behavior With web.xml 說到
1
2
If a session has not been accessed for a certain period of time, the server can throw it
away to save memory.

因此,除非特殊需求,不應如此,
若 user 關閉瀏覽器,再重新啟動,則先前所建立之 session 仍存於 memory 中,卻很可能不再有任何作用,
如此將造成很多無用的 session 佔住 memory。


reply to postreply to post
作者 Re:TOMCAT怎么配置SESSION 失效时间? [Re:Kaede]
flair





發文: 30
積分: 0
於 2007-10-06 08:03 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
那要如何才能避免 user 關閉瀏覽器,再重新啟動,則先前所建立之 session 仍存於 memory 中呢

reply to postreply to post
作者 Re:TOMCAT怎么配置SESSION 失效时间? [Re:Kaede]
Bahamut





發文: 3
積分: 0
於 2007-10-31 01:45 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
你可以用COOKIE代替SESSION

reply to postreply to post
» JWorld@TW »  Application Server » Tomcat

reply to topicthreaded modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8