Im currently studying for SCWCD certification and i just faced on doubt.
Whats the difference between getSession() and getSession(true)
from Oracle specification:
Since both returns the current HttpSession associated with the request or, if there is no current session, returns a new session.
If they do same thing, whats the point of having both?
Amit Ghorpade wrote:The getSession() is same as getSession(false). That means you don't get any session if it does not exist before getSession() is called.
Whereas getSession(true) always returns a session, either the existing one or a new one if none exists.
Hope this helps
In the link i can see:
"HttpSession getSession() = Returns the current session associated with this request, or if the request does not have a session, creates one."
As far i understand getSession() its the same as getSession(true), and not getSession(false), right?
So, i was wondering why have both methods, if getSession(boolean x) alread satisty both situations.