• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tomcat restarted and session still work?

 
William Yan
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ranchers,
I am new to Serlvets.
I put this in my servlet.


When the client has visited this servlet once, I shut down Tomcat and restart it. And then when the client revisited the servlet, the page shows 'welcome back!' I don't know why? Isn't session stored in Tomcat? And when the server is shut down and restarted, all the session disppear? Or be serialized? and where?

Thank you in advance.
Yours,
William.
 
Aleena Rehman
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont know but may be your browser is picking up the cached page.

Try one thing if you are using IExplorer.

(1) Go to Tools > Internet Options > General Tab
(2) On Temporary Internet Files section, click Settings
(3) On the newly opened dialog, select 'Every Visit to Page' option and press OK.

Retry your scenario and let us know.

Regards,
 
William Yan
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, Aleena,
I just visit the servlet only once, by FireFox (get 'hello, new').
Then shut down the Tomcat and restart it.
Then visit the servlet again (2nd time), And get 'welcome back'.

Thank you.
 
Gowher Naik
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use session.invalidate() to destroy session.
 
Gowher Naik
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am also using FireFox and i encountered same problem
Then i use session.invalidate() and my problem was solved
You can also use session time out in DD.
But if you are using Internet Explorer this problem will not occur.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tomcat's default session manager will persist sessions. That is why the session is still there.

Tomcat Manager Component
 
William Yan
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot.
Thank you, Satou for your link.
 
Gowher Naik
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
William can you tell me what you have done to destroy session if you are not using session.invalidate().
 
William Yan
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi gowher,
I DO use invalidate().
I am just wondering WHY Tomcat is shut down and restarted the former session can still work.
 
Gowher Naik
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi William
i think i got solution.
following procedure shown below
on Mozilla firefox Browser click
Tools->Options-->Exceptions->
in Address of web site TextBox Write url for which you want to destroy session
Click Block Button
Click Close-->Ok to close browser window.

Then run your program once
Then restart Tomcat and check result
Use session.getId() to check session id.
Please inform if you find anything new.
 
William Yan
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi gowher,

Yes, i can clear the cookies of the browser.
But you cannot expect all your clients to do complicate things like clearing the cookies when you want to destroy all the sessions and have new ones(e.g you have updated your servlet and want the whole app to be new). As Satou said, "Tomcat's default session manager will persist sessions.", you may alter the configure of tomcat to make tomcat not to persist sessions(but i haven't got it), then all will be right.

Yours,
William
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic