Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

does session remain alive even if i shuts down the server in tomcat?

 
Santosh Jagtap
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i started the server and hit the url for myfile so a new session got created.
now i shut down the server (not the browser).
and started it again .and refreshed the page.
then in this case will i get new session id or the same id will be continued (which was assigned to me at first time) in tomcat?
 
Neeraj Vij
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
unless you have save your state in some secondary storage...server will start a new session.

cheers!!
Neeraj.
 
Santosh Jagtap
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Neeraj Vij:
unless you have save your state in some secondary storage...server will start a new session.

cheers!!
Neeraj.


yeah thts true if i haven't persisted my session object i wont get the same object but its happening
what i did is
i created 3 jsp pages
1 - containing 2 buttons one for setsession attr and another for getsession attr
2 - for sesetting session attribute by name "myName" value is "Santy"
3 - for getting and printing session attribute "myName"

i hitted the url for the first jsp and clicked on set session button the second file get called and the attribute is stored in session by name myname with value "Santy"
then i pressed back button and clicked on get button ,the third file get called and printed "Santy"
then again i clicked on back button

now i restarted the server refreshed the first jsp and called directly third file .even then i got the output as "Santy"
 
Neeraj Vij
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

humm...

Just for my help..

1.)before restarting the server clear the browser history and delete all temp. internet files which contains cookies too.
2.)then try to get the seesion variable value.


rgds,
Neeraj.
 
Santosh Jagtap
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Neeraj Vij:
Hi,

humm...

Just for my help..

1.)before restarting the server clear the browser history and delete all temp. internet files which contains cookies too.
2.)then try to get the seesion variable value.


rgds,
Neeraj.


Hi
I tried tht still it prints the value.But onething is it happens only with tomcat i tried on oc4j it printed null.
 
Neeraj Vij
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



try it by clearing the temp. work area directory of tomcat.

rgds,
Neeraj.
 
Santosh Jagtap
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah i tried tht also still it is coming...
i think tomcat must be persisting each session...
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Servlet engines are allowed to serialize sessions out to disk - thats why it is a good idea to make sure all objects "stored" in sessions are Serializable. Take a look at your server.xml file in Tomcat for references to persistent sessions.
Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic