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

HttpSession question

 
Tuna Töre
Ranch Hand
Posts: 220
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


why the above code didn't print session is new when I call it every time ?
I observe that it print only one time ?

isn't it suppose to open a new session when I request it...

Thanks...
 
Charles Lyons
Author
Ranch Hand
Posts: 836
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, not on every request! getSession(true) will return the existing session if one exists, or a new session only if one does not already exist. Compare with getSession(false) which returns the existing session if one exists, or null if one does not already exist.
 
Tuna Töre
Ranch Hand
Posts: 220
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Charles Lyons:
No, not on every request! getSession(true) will return the existing session if one exists, or a new session only if one does not already exist. Compare with getSession(false) which returns the existing session if one exists, or null if one does not already exist.






okay then I changed my code like that and everytime it gave me a new session

Thank you for your response I got it ...
 
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!