getSession() Vs getSession(boolean)
if in my project i am using just getSession() and not getSession(boolean), what kind of troubles i can get into. what is the disadvantage of getSession(). There must be many of this approach (of using only getSession() ) since for getSession() i will always get a session even if my session expires...right? so will there be data inconsistencies?
# 1
hi,
getSession()
Returns the current session associated with this request,
*) if the request does not have a session, creates one.
getSession(boolean )
Returns the current HttpSession associated with this request.
*) if there is no current session and getSession(true) then it returns a new session.
if u give getSession(false) then it returns a null,
# 3
There are certain cases where if you do not have an existing session, you don't want it to create one for you. In those cases you would call getSession(false).
The call to getSession() is to handle the general case where you always want a session. There is no disadvantage in using it, just that it isn't applicable in some cases.