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

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

    request.getSession().getId();
    

    Will return unique string id assigned to already started session. Generation of id is vendor specific like apache, jboss etc.

    request.getSession(false);
    

    It will return session object associated to particular request if session object is associated it will be returned or it will return null if its is not started by server.

提交回复
热议问题