This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma 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
Rancher

Joined: Mar 22, 2005
Posts: 42958
    
  73

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.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

I GOT IT ULF.THANK YOU SOMUCH
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Doubt on session() and session(false)
 
It's not a secret anymore!