Difference between request.getSession().getId() and request.getSession(false)?

前端 未结 8 722
礼貌的吻别
礼貌的吻别 2021-01-31 04:08

What do these calls actually mean in terms of session?

System.out.println(\"print1: \"+request.getSession().getId());
System.out.println(\"print2: \"+request.get         


        
8条回答
  •  [愿得一人]
    2021-01-31 04:55

    request.getSession().getId();
    

    this will return the id of the an existing session.

    Request.getsession(false) 
    

    it will return the session if it exists, or it will return null otherwise.

    and Request.getsession(false) means : give me the session if it exists, otherwise do not create a new instance (and thus return null).

提交回复
热议问题