• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

HFSJ Mock Questions.

 
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.







 
Sheriff
Posts: 9671
42
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • 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.
 
Ranch Hand
Posts: 463
Eclipse IDE Tomcat Server Java
  • 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 Tomcat Server Java
  • 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)
 
Ranch Hand
Posts: 437
Oracle Java
  • 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 Tomcat Server Java
  • 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!
 
What do you have to say for yourself? Hmmm? Anything? And you call yourself a tiny ad.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic