File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Q6 from chap 5 of HSFJ Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Q6 from chap 5 of HSFJ" Watch "Q6 from chap 5 of HSFJ" New topic
Author

Q6 from chap 5 of HSFJ

vijaya bacina
Ranch Hand

Joined: Aug 23, 2005
Posts: 155
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???
Will Lee
Ranch Hand

Joined: Mar 16, 2005
Posts: 58
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".


SCJP 1.4, SCWCD, SCDJWS
Rizwan Mohammad
Ranch Hand

Joined: Sep 02, 2005
Posts: 445
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."


Rizwan
SCJA, SCJP, SCWCD, SCBCD, SCDJWS.
vijaya bacina
Ranch Hand

Joined: Aug 23, 2005
Posts: 155
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

Joined: Aug 23, 2005
Posts: 155
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??
 
 
subject: Q6 from chap 5 of HSFJ