Win a copy of Spark in Action this week in the Open Source Projects forum!
  • 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Q6 from chap 5 of HSFJ

 
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it was given
"ServletContextListener can be used to perform an action when the servlet context is about to be shut down."

But ContextDestroyed() method is called only after Context is destroyed... Am i correct???
 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public void contextDestroyed(ServletContextEvent sce)

Notification that the servlet context is about to be shut down. All servlets have been destroy()ed before any ServletContextListeners are notified of context destruction.

Therefore I guess this listener give you last chance to clean up the resource of this app., AFTER all servlets are gone. At this moment app (context) is still there.

Am I right? As a matter of fact I am really confused about the post-fix (-ed) and "about to be".
 
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, from method name it looks obvious as method gets called after context is destroyed.
But according to servlet specification, it will be called just before session is destopyed.
I am pasting the below lines, as it is from servlet specification about ServletContextListener life cylce methods(contextInitialized, contextDestroyed).

"The servlet context has just been created and is available to service its first request, or the servlet context is about to be shut down"

About contextDestroyed method from J2EE API..

"Notification that the servlet context is about to be shut down. All servlets and filters have been destroy()ed before any servletContextListeners are notified of context destruction."
 
vijaya bacina
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so contextDestroyed() is called when the context is about to destroy

how many questions we may expect from thread-safe servlets in 310-081 exam???
 
vijaya bacina
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
attributeAdded(),attributeRemoved(),attributeReplaced() are called after event happens..
but getValue()returns attribute that has been added removed or replaced..means old value....am i right??
 
Opportunity is missed by most people because it is dressed in overalls and looks like work - Edison. Tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic