• 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.isNew() is always returning false

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

I just tried with a small servlet test.

In the servlet



Am always getting old session value. I tried with clearing cookies and restarted tomcat. Some times am getting new session Id and session creation time. Please assist me

I tried in IE
 
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
have you referenced this servlet from a jsp???

avi sinha
 
Meet Gaurav
Ranch Hand
Posts: 492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes
 
avi sinha
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in jsp session is created by default. when your request reaches the servlet the session has already been created.

in jsp write :


and you will get the desired behaviour.

avi sinha
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
isNew returns true the first time the server sees the user, and you are assuming that te first time the server sees the user, your code is being run.
I am not sure about the specifics of your application, but this obviously isn't true.
Rather than getting bogged down in the behaviour of a single method, have you tried reading a session value and then writing it if the value does not yet exist?

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

avi sinha wrote:in jsp session is created by default. when your request reaches the servlet the session has already been created.

in jsp write :


and you will get the desired behaviour.

avi sinha




Hi Avi.. I tried with this evan after restarting the server same issue.. Always old session value
 
Meet Gaurav
Ranch Hand
Posts: 492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
session.isNew() is always returning false
 
avi sinha
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Meet Gaurav wrote:session.isNew() is always returning false



open the jsp page in your browser and check the cookies . if a cookie JSESSIONID id there for your host then the problem is in your jsp not in the servlet.

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

It might be an old post. But was really helpful and you made my day... thanks a lot

Regards,
Gandhi
 
reply
    Bookmark Topic Watch Topic
  • New Topic