If you want to know whether it valid based on a request:
request.isRequestedSessionIdValid()
or
HttpSession sess = request.getSession(false);
if (sess != null) {
// it's valid
}
If you have stored a reference to the session and need to validate I would
try {
long sd = session.getCreationTime();
} catch (IllegalStateException ise) {
// it's invalid
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…