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

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

    request.getSession().getId()
    

    Returs the id of the session.

    Request.getsession(false) returns the already existing session object. It wont return anything i.e. Will return null , if session does not exist. Whereas with true parameter it will create a new session object and return it if no session exists

提交回复
热议问题