Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
752 views
in Technique[技术] by (71.8m points)

how to check session has been expired in java?

Is there any other way to check expiry of session other than this

session.isNew()

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Yes:

  • you can call HttpServletRequest.getSession(false) and you'll get a null instead of a session if there isn't one active already.

  • you can define a lifecycle listener (using HttpSessionListener) in your web.xml. That way you can get notified the moment a session bites the dust.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...