if(session.getAttribute("foo") == null){ // Session does not exist (Actually, the attribute just isn't set, but it works) }else{ // Session does exist }