• Post Reply Bookmark Topic Watch Topic
  • New Topic

Session Problem

 
sarath rachakonda
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
 
Amit Ghorpade
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.
 
Seetharaman Venkatasamy
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.
 
Lucky Chauhan
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!