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

前端 未结 8 734
礼貌的吻别
礼貌的吻别 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 05:05

    In short-

    request.getSession().getId() - returns a string containing the unique identifier assigned to this session. The identifier is assigned by the servlet container and is implementation dependent.

    request.getSession(false) - return session object or null if there's no current session.

提交回复
热议问题