• Post Reply Bookmark Topic Watch Topic
  • New Topic

What's still in scope during Servlet.destroy() method?

 
Dan Bizman
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When my servlet's "public void destroy()" method is called, can I get attribute's (i.e. objects) saved in the ServletContext?
In other words, in destroy, do something like:
Closeable obj = ( Closeable ) getServletContext().getAttribute( "MyCloseable" );
obj.close();
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only problem I can think of is that you could not rely on the order in which the destroy method of various servlets in a given web application are called. Otherwise, that is exactly what the destroy method is supposed to be used for.
Bill
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!