This week's book giveaway is in the Artificial Intelligence forum.
We're giving away four copies of Pragmatic AI and have Noah Gift on-line!
See this thread for details.
Win a copy of Pragmatic AI this week in the Artificial Intelligence forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Session Problem  RSS feed

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have code which has to get the existing session from the request and use it but the behaviour of request.getSession() is strange and i couldn't understand.
I know that request.getSession() will return existing session if it is there otherwise creates new session and returns.But in my case though there is a session in the request, request.getSession() is creating new session. But when i say request.getSession(false) it is returning existing session.
Can anybody explain why request.getSession() is not returning existing session.

Thanks,
Sarath
 
Bartender
Posts: 2856
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The request.getSession() is same as request.getSession(true).
Does session.isNew() return true?
take a look at the doc's.
 
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

sarath rachakonda wrote:
I know that request.getSession() will return existing session if it is there otherwise creates new session and returns.


Correct

sarath rachakonda wrote:
Can anybody explain why request.getSession() is not returning existing session.



I am not sure about your problem. but as you mentioned above it should return existing session.
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi sarath,
after seeing your problem i firstly thought that you might have blocked your cookies but if request.getSession(false) is returning the existing session then request.getSession() or request.getSession(true) should also return the same.Check the sessionId returned by request.getSession(false) with your existing session(ie session.getId()) .


Sachin Chauhan
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!