Difference between request.getSession() and request.getSession(true)

后端 未结 7 1736
难免孤独
难免孤独 2021-01-31 08:43

I understand the difference between request.getSession(true) and request.getSession(false). But request.getSession() & request.g

7条回答
  •  再見小時候
    2021-01-31 09:04

    Method with boolean argument :

      request.getSession(true);
    

    returns new session, if the session is not associated with the request

      request.getSession(false);
    

    returns null, if the session is not associated with the request.

    Method without boolean argument :

      request.getSession();
    

    returns new session, if the session is not associated with the request and returns the existing session, if the session is associated with the request.It won't return null.

提交回复
热议问题