Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

session persistance from server perspective

 
yogesh srinivasan
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

I wrote a simple code to understand sessions.
This code creates a session and adds a cookie and an attribute to a new session.
I restarted the tomcat and refreshed the stale browser. The session and its attribute were retained by the browser.
I thought the session and its attributes were created in server's memory and would be destroyed after the restart.
How this is possible?
 
Devaka Cooray
Marshal
Pie
Posts: 4879
402
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yogesh srinivasan wrote:This code creates a session and adds a cookie and an attribute to a new session.

yogesh srinivasan wrote:The session and its attribute were retained by the browser.


Well,... I can't see a session attribute in your code. Can you?

Devaka.
 
yogesh srinivasan
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oops..sorry forgot to add the latest code

 
Sourin K. Sen
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
tell us the outputs that you are getting prior to restarting the server and after restarting it.
 
yogesh srinivasan
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
step1 : create a sample home.html with a form triggereing the test servlet
step2 : output
Session.isNew=true
session ID42D3279AE5EF2FE634F0ECE96CAA583A
session MaxInactivInterval 1800
session attirbute1 value= 3
step3 : hit the back button and resubmit home.html
step 4 : output
Session.isNew=false
cookie name= cookie1 value= 3 maxAge= -1
cookie name= JSESSIONID value= 42D3279AE5EF2FE634F0ECE96CAA583A maxAge= -1
session ID42D3279AE5EF2FE634F0ECE96CAA583A
session MaxInactivInterval 1800
session attirbute1 value= 3
step 5 : shutdown and restart tomcat
step 6 : hit back button and resbmit
step 8 : output
Session.isNew=false
cookie name= cookie1 value= 3 maxAge= -1
cookie name= JSESSIONID value= 42D3279AE5EF2FE634F0ECE96CAA583A maxAge= -1
session ID42D3279AE5EF2FE634F0ECE96CAA583A
session MaxInactivInterval 1800
session attirbute1 value= 3

[I created 3 request to increment the cookieCount value]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic