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?

[353 byte] By [javanewbie80a] at [2007-11-27 9:32:26]
# 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,

drvijayy2k2a at 2007-7-12 22:49:59 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
right thats true, thats there in the documentation. i was wondering if someone could tell me the disadvantages of such approach (of using just getSession())
javanewbie80a at 2007-7-12 22:49:59 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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.

evnafetsa at 2007-7-12 22:49:59 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
yea..thats what..i want to know about those certain cases...
javanewbie80a at 2007-7-12 22:49:59 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...