• 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 persistance from server perspective

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 7141
1360
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
oops..sorry forgot to add the latest code

 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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]
 
Think of how stupid the average person is. And how half of them are stupider than that. But who reads this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic