Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HFSJ Mock Questions.

 
Nabila Mohammad
Ranch Hand
Posts: 664
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.







 
Ankit Garg
Sheriff
Posts: 9521
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Nabila Mohammad
Ranch Hand
Posts: 664
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 463
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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.
 
Nabila Mohammad
Ranch Hand
Posts: 664
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 463
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 664
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chapter 5 Attributes and Listeners , Question 6 (b)
 
Chinmaya Chowdary
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 463
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 664
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic