Help coderanch get a
new server
by contributing to the fundraiser
  • 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 related Questions

 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have confusion in the foll questions ( from Marcus Green).

State whether true or false :-


1) A session will always be invalidated if a user shuts down his browser.

2) A session will always be invalidated if the servlet container restarts.

3) Data in a HttpSession attribute will not be available if the web server restarts.


According to me , A and B should be TRUE
C should be FALSE

Am I right ? If any of my answer is wrong could you please explain why.

Please help , I plan to give the exam in next 15 days.
 
Creator of Enthuware JWS+ V6
Posts: 3411
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Simran,

All the answers should be false, here my explanations:

1) A session will always be invalidated if a user shuts down his browser.


The server doesn't know that the browser (client) has gone, so it won't invalidate the session. It will only be invalidated after a session-timeout

2) A session will always be invalidated if the servlet container restarts.


Some servlet-containers store their sessions on disk when there is a system-failure or close down.

3) Data in a HttpSession attribute will not be available if the web server restarts.


Because of the previous answer the data could be recovered from disk. However all attributes put into the session object should then be Serializable.

Regards,
Frits
 
Simran Dass
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Thanks a lot Frits .

Say we remove the word always from this sentence and have may/might instead i.e. -

" A session might be invalidated if the servlet container restarts " then will it be true bec' some containers might not store a session on disk.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Posts: 3411
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Correct!

Be very keen on those words during your exam.

Regards,
Frits
 
Ranch Hand
Posts: 252
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I try it out on my computer - restart the tomcat service and then access the various attributes - the session attribute value is still available (though the application attributes have been lost ofcourse).

So is this container dependent or will the session object always exist, till it times out or is invalidated?
 
Frits Walraven
Creator of Enthuware JWS+ V6
Posts: 3411
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nidhi,

So is this container dependent or will the session object always exist, till it times out or is invalidated?


As it is nowhere mentioned in the servlet spec that a session object should survive a system-failure or close down you can say that it is container dependent

Regards,
Frits
 
Opportunity is missed by most people because it is dressed in overalls and looks like work - Edison. Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic