私はいつ知りたいのですか正確に HttpSessionはになります(破損と同じではありません)?私はsession.getLastAccessedTime()+(session.getMaxInactiveInterval()* 1000)私の要求が同じセッションIDが付属していますたびに、セッションの有効期限をミリ秒単位で正確な時間を与える場合は!把握しようとしていますHttpSessionが期限切れになったとき(破棄の対象となり始めるが、必ずしも破壊される必要はない)?
javadocから
:
長いgetLastAccessedTime()
Returns the last time the client sent a request associated with this session, as the number of milliseconds since midnight January 1, 1970 GMT, and marked by the time the container received the request.
int型getMaxInactiveInterval()
Returns the maximum time interval, in seconds, that the servlet container will keep this session open between client accesses.
には、以下の我々が持っているとしましょう:
Treq1 - the time the container received the 1st request
(HttpSession.lastAccessedTime)
Tresp1 - the time the container sends the 1st response
Preq1 - the time period between Treq1 and Tresp1 (the time period that the server processes the 1st request
Treq2 - the time the container received the 2nd request
(HttpSession.lastAccessedTime)
Preq1req2 - the time period between Treq1 and Treq2 (the time between requests entering the container)
Presp1req2 - the time period between Tresp1 and Treq2 (the time between the 1st response exiting the container and the 2nd request entering the container)
だから今、サーバが計算しませんセッションは期限切れですか?:
1 Treq1 + maxInactiveInterval < Treq1 + Preq1req2 =>maxInactiveInterval < Preq1req2
2 Tresp1 + maxInactiveInterval < Tresp1 + Presp1req2 =>maxInactiveInterval < Presp1req2
この部分、the servlet container will keep this session open between client accesses
であります少し紛らわしい。コンテナに入る要求間、または応答の終了と要求の入力の間に意味がありますか?サイドノートで
、私はセッションが期限切れの正確な時に破壊されない可能性があることを知っているが、いずれの要求処理ロジックがで発生する前に、それが破壊された場合、私はまだ知りませんコンテナ期限切れのセッションIDを保持しているリクエストを参照しています。
種類よろしく、
専制君主
なぜ重要ですか?要求の時間は、通常、数ミリ秒である。セッションタイムアウトは通常30分です。 30.000か30.002かどうかは重要ですか?あなたの最終目標は何ですか? * –
クライアントがセッションが期限切れになる時刻を正確に知りたいので、重要です。 "答えは質問にあります:コンテナが要求を受け取った時点でマークされています"これはlastAccessedTimeを参照するだけかもしれません。有効期限がsession.getLastAccessedTime()+(session.getMaxInactiveInterval()* 1000)(1. case)になることは確かですか?それを確認できる情報源はありますか?コメントありがとう! – despot
これはミリ秒に正確にしたいですか? 30分後、30分後、8ミリ秒後のエンドユーザのケアはありますか?とにかく、コンテナは通常1分ごとに期限切れのセッションを破棄するバックグラウンドスレッドを使用するため、その時点でセッションは破棄されません。 –