This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SESSION related Questions

 
Simran Dass
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • 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.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2534
113
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • 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
  • 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
Saloon Keeper
Pie
Posts: 2534
113
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Correct!

Be very keen on those words during your exam.

Regards,
Frits
 
Nidhi Sar
Ranch Hand
Posts: 252
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • 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
Saloon Keeper
Pie
Posts: 2534
113
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic