Here is the syntax for getting the session object without any parameter.
HttpSession session=request.getSession();
above statement will returns the current session associated with the request and if it does not exist, a new session will be created.
HttpSession session = request.getSession(true);
above statement will returns the current session associated with the request and if session doesn't exit, a new one will be created.
So above two statements have no difference.
HttpSession session =request.getSession(false);
above statement will returns the current session if session exists and if there's no valid session, a new session will not be created, it will return null.
.
0 comments:
Post a Comment