• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

session's invalidation behaviour

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

Here is a question:

In which of the following situations will a session be definitely invalidated?

Select 3 correct options.
A.The container is shutdown and brought up again
B.No request comes from the client for more than "session timeout" period.
C.A servlet explicitly calls invalidate() on a session object.
D.A servlet explicitly calls invalidate() on a session object.
ANS : B,C,D

My Question is: Is there a possibility that a session might not be invalidated even the container is restarted? this relates to option A.

Thanks and regards,
Saurabh
 
Ranch Hand
Posts: 215
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Saurabh,

Yes it is possible that a session is not invalicdated if the container is shutdown and then restarted. I have done this on Tomcat, infact if memory serves correctly its the standard behaviour on tomcat.

For example create a servlet/jsp that saves something into the HttpSession. then another that displays what was saved in the HttpSession

Point your browser at the first one, wait till the page comes up, then shut the server down, and restart it. Then point your browser at the second page.

I have done this with tomcat and had what was save into the session displayed on the page. The simple reason is that Sessions are serialised to the file system and then reloaded from the filesystem on a new request. Tomcat does not clear its cache of session data when restarted so its still there.

HTH
Matt
 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How is option C different from Option D ??
 
Mat Williams
Ranch Hand
Posts: 215
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Option C and D are identical
I was assuming (maybe incorrectly) that one was just a typo.

Matt
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Matt,
Thanks for your reply. To add to the concept, this supports the behaviour of a web application in distributed environment. Now if a server goes down the application still has to run and this can't happen if the sessions objects (living in that server) get invalidated when server goes down.

Saurav,
Please let me know the option D. I want to know what is the third way of invalidating the session.

Cheers
Tanveer
 
Saurabh Kumar
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Mat, Tanveer.

I found this question hereJavaBeat

I copied the question as is, I ignored this considering it "typo".

If you find something relevant to Tanveer's question, please let me also know.

Thanks and regards,
Saurabh
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic