- - PR -
セッションのタイムアウトの設定について
1
投稿者 | 投稿内容 |
---|---|
|
投稿日時: 2005-11-04 12:51
いつもお世話になります。いのきです。
今日2度目のスレで皆様にご迷惑をおかけいたします。 今度の問題は、セッションについてなのですが、javaソースで、「HttpSession」を使用して、セッション取得(request.getSession)やパラメータ設定(session.setAttribute("XXX", "XXX"))を行っています。 問題になるのが、セッションのタイムアウトです。セッション終了(session.invalidate())を行っていないにも関わらず、セッションが切れてしまう状態です。 そこで、セッションのタイムアウト設定をjavaソースで無制限にしようと思うのですが、可能なのでしょうか? 度々で恐縮なのですが、ご存知の方がいましたらご教授をお願い致します。 |
|
投稿日時: 2005-11-04 14:19
Java? Servlet Specification Version 2.4 より引用いたします。
------------- SRV.7.5 Session Timeouts In the HTTP protocol, there is no explicit termination signal when a client is no longer active. This means that the only mechanism that can be used to indicate when a client is no longer active is a timeout period. The default timeout period for sessions is defined by the servlet container and can be obtained via the getMaxInactiveInterval method of the HttpSession interface. This timeout can be changed by the Developer using the setMaxInactiveInterval method of the HttpSession interface. The timeout periods used by these methods are defined in seconds. By definition, if the timeout period for a session is set to -1, the session will never expire. The session invalidation will not take effect until all servlets using that session have exited the SESSIONS Final Version 60 service method. Once the session invalidation is initiated, a new request must not be able to see that session. ------------- 一応タイムアウトしない設定にはできますが、いずれヒープの枯渇から OutOfMemoryError 至ることになりますので強くお勧めしません。 [ メッセージ編集済み 編集者: インギ 編集日時 2005-11-04 14:20 ] |
|
投稿日時: 2005-11-04 19:25
いつもお世話になります。いのきです。
インギ様、ご回答ありがとうございました。 私の方でも色々調査しているのですが、インギ様のおっしゃるように、 完全にエラーを発生させないということはできないみたいですね。残念・・・。 もうちょっと調査してみます。 ありがとうございました。 |
|
投稿日時: 2005-11-04 19:56
セッションタイムアウト自体は、アクティブでないセッション情報を破棄してヒープを確保し、サーバ状態を健康に保つための仕組みですのでエラーではありません。
セッションタイムアウトに起因して何らかのエラーが発生しているのであればアプリケーションの問題と言えます。 セッションはタイムアウトする可能性があることを十分に想定したコードを書きましょう。 |
|
投稿日時: 2005-11-07 18:26
いつもお世話になります。いのきです。
インギ様、ご返答が遅くなり、大変申し訳ありませんでした。 インギ様のご指摘の通り、セッションのタイムアウトを無制限にするのではなく、タイムアウトを考慮した内容でいくことにしました。 誠にありがとうございました。 |
1