如何判断session是否过期

if(request.getSession(false)==null){
System.out.println("session过期了");
}
如果session不存在了就表示是过期了
Objectibcode=request.getSession().getAttribute(ConstantFields.IB_CODE);
if(null==ibcode||"".equals(ibcode)){
System.out.println("session过期了");
}
如果session不存在了就表示是过期了