Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

getsession(false)

 
sri rallapalli
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

getSession(false), is returning an existing session and null if nothing is available, if that is the case, then creating a session in normail way, i.e.
HttpSession session = request.getSession();
HttpSession session = request.getSession(true);
in both the above ways, it is always creating a new session, so if we call isNew() on the session object then we should always get true, and if its always true, then how can we maintain session?

Regards,
Sri.
 
Ali Gohar
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in both the above ways, it is always creating a new session


No, request.getSession() will first check if its existing session, then it will return that otherwise will create new one.
[ March 21, 2007: Message edited by: Ali Gohar ]
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!