wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes HFSJ Mock Questions. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "HFSJ Mock Questions." Watch "HFSJ Mock Questions." New topic
Author

HFSJ Mock Questions.

Nabila Mohammad
Ranch Hand

Joined: Nov 05, 2007
Posts: 661
There is a statment in the mock questions on HFSJ

"Servlet Context should be used for data that changes rarely"

Can any one explain this.
I thought it should be used for data that changes frequently (if its dependent on the data)





When talking about listeners, there is are two statements.


- HttpSessioniListener can be used to perform an action when HttpSession is timed out.
-a ServletContxtListner can be used to perform actoin when the servlet is about to shut down


I thought the answers should be similiar.
When it is "about to" shutdown or "after it shuts down"

How come its mentioined when session is timed out...and servle is about to shut down.








The future belongs to those who believe in the beauty of their dreams.Dream BIG!
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

The documentation of contextDestroyed says

Notification that the servlet context is about to be shut down.

and the documentation for sessionDestroyed says

Notification that a session is about to be invalidated.


The behavior of sessionDestroyed was changed in Servlet specification 2.4. Before that the sessionDestroyed was called after the session was invalidated...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Nabila Mohammad
Ranch Hand

Joined: Nov 05, 2007
Posts: 661
I am not sure if i got it..

the documentation says
Notification that a session is about to be invalidated.
The session is going to be destroyed and not destroyed yet

How is it similiar to HttpSession is(already) timed out.
Sai Surya
Ranch Hand

Joined: Feb 08, 2006
Posts: 457

"Session is about to invalidate ... " so in order to give some time to do clean up etc if any. After session gets invalidated we cannot do anything with it.

Sai Surya, SCJP 5.0, SCWCD 5.0, IBM 833 834
http://sai-surya-talk.blogspot.com, I believe in Murphy's law.
Nabila Mohammad
Ranch Hand

Joined: Nov 05, 2007
Posts: 661
Ok.. i got that..

then why is this statement true (According to HFSJ)

HttpSessioniListener can be used to perform an action when HttpSession is timed out.

How can HttpSessionListener be used when the session is timed out and already destroyed in contrast to about to be invalidated
Sai Surya
Ranch Hand

Joined: Feb 08, 2006
Posts: 457

Nabila Mohammad wrote:Ok.. i got that..

then why is this statement true (According to HFSJ)

HttpSessioniListener can be used to perform an action when HttpSession is timed out.

How can HttpSessionListener be used when the session is timed out and already destroyed in contrast to about to be invalidated


Can you tell me which chapter and mock exam question number?
Nabila Mohammad
Ranch Hand

Joined: Nov 05, 2007
Posts: 661
Chapter 5 Attributes and Listeners , Question 6 (b)
Chinmaya Chowdary
Ranch Hand

Joined: Apr 21, 2008
Posts: 432
Hi Nabila.

When session is timed out, then it is eligible for invalidate. At this time the session will not be invalidated. If the application implements HttpSessionListener, it notifies that the session is about to invalidated via. sessionDestroyed() method. If we want to cleanup any resources, that should be placed there. After everything is done, then the session will be invalidated.
Sai Surya
Ranch Hand

Joined: Feb 08, 2006
Posts: 457

I think the anser (b) should have been like this :

An HttpSessionListener can be used to perform an action when an HttpSession is about to time out.
Nabila Mohammad
Ranch Hand

Joined: Nov 05, 2007
Posts: 661
ok..
that means time out and invalidate are two separate things.
When session is timed out , its not yet invalidated . but comes elegible for invalidation.

So we can still perform actions , Right?

Thanks! That made it clear!
 
wood burning stoves
 
subject: HFSJ Mock Questions.
 
Similar Threads
HFSJ Mock exam for chapter 5
session listener
Question for Kathy
Q6 from chap 5 of HSFJ
Coffee Cram - Chapter 5 (Attributes and Listeners)