HttpSession session = request.getSession(false);<%--Passing "false" means the method returns a pre-existing session or null if there was no session associated with this client.--%>
if(session == null){
session = request.getSession();
}
if(session == null){
session = request.getSession();
}