aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes SESSION related Questions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "SESSION related Questions" Watch "SESSION related Questions" New topic
Author

SESSION related Questions

Simran Dass
Ranch Hand

Joined: Jan 09, 2010
Posts: 183
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
Bartender

Joined: Apr 07, 2010
Posts: 1675
    
  25

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

Joined: Jan 09, 2010
Posts: 183


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
Bartender

Joined: Apr 07, 2010
Posts: 1675
    
  25

Correct!

Be very keen on those words during your exam.

Regards,
Frits
Nidhi Sar
Ranch Hand

Joined: Oct 19, 2009
Posts: 252

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?


"A problem well stated is a problem half solved.” - Charles F. Kettering
SCJP 6, OCPJWCD
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1675
    
  25

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SESSION related Questions