• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Session Problem

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic