This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Servlets and the fly likes Doubt  on session() and session(false) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "Doubt  on session() and session(false)" Watch "Doubt  on session() and session(false)" New topic
Author

Doubt on session() and session(false)

Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Hi All,


HttpSession session=request.getSession(true); this will create new session

and HttpSession session=request.getSession(false); this will maintain existing session right?


if yes, i should get out put like
-------------------------------------------
EXISTING SESSION 1ST SESSION

NEW SESSION [empty]


-------------------------------------------

but i am getting:
---------------------------------------
EXISTING SESSION 1ST SESSION
NEW SESSION 1ST SESSION
---------------------------------
please explain me . Hope you understand my point

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42022
    
  64

HttpSession session=request.getSession(true);

this will create new session

Not necessarily. If a session exists already, it will return that one. The first paragraph of the javadocs of getSession(boolean) mentions this.


Ping & DNS - my free Android networking tools app
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

I GOT IT ULF.THANK YOU SOMUCH
 
Consider Paul's rocket mass heater.
 
subject: Doubt on session() and session(false)