what if I want to know whether the session already existed or was just created?

Put the following code into you java code :

HttpSession session = request.getSession();/*getSession()returns a session no matter what...but you can't tell if it is a new session unless you ask the sesssion.*/

if(session.isNew()){  /*isNew()returns true if the client has not yet responded with this session ID*/
//put your java code here
}else{
//put your java code here
}

你可能感兴趣的:(isNew())