• 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
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

Doubt in Session.isNew()

 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I have this code in a servlet



i undertand that getSession() and getSession(true) will create a session if already not present and return the one if present and getSession(false) will return if session already exists and null if not.

The server for the very first request will append the sessionId both in URL and cookie and later depending up on clients settings either on theURL or cookie only.

But when i ran this code for the very first time it behaved orrectly.isNew() returned true but later when i killed the session through invalidate and restarted the server,cleared the cookies and ran the servlet now once again the isNew() should return true instead it is always returning false.that means the session already exists what actually is happening here.

Thanks
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try getting the cookie in the servlet and printing it. If you can get the cookie then probably you are not properly cleaning up the cookie on the client.
 
raja ram
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Yes I am able to get the session cookie in my forwarded servlet. but i have cleared the private data selecting cookies.

Thanks
 
Ranch Hand
Posts: 392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Raja,
which browser are you using.
I think the cookie is not getting cleared in this case..
 
raja ram
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am using Mozilla

Thanks
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Add the following line to your Servlet. Seeing if the ID is really the same is important in isolating the issue.

It's possible that a new session is getting created by a JSP after the first session has been invalidated. JSPs always participate in a session (and thus also create a new one) unless they contain a page directive with session="false".
 
raja ram
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I added getID() in to my servlet and first i tried with Mozilla i got isNew() false and ID as 62B7411E75C79720CF89C617FEDD5866
again i opened IE 6.0 cleared all the cokies and private data once again i got isNew() false and ID as ADC7C04E309AC4717804A5130A5C4EF9

different session id but isNew() false. I think two seperate sessions are created but isNew() always returns false and i am using servlet and not the Jsp only first screen to invoke a servlet is JSP both creating of session and retriving it from cookies are also in servlet.

Am i missing any thing here.

Thanks
 
raja ram
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Any updates on this issue.

Thanks
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic