You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by nam3l3ss <th...@gmail.com> on 2008/04/24 16:48:54 UTC
Application scope bean destruction?
Hi!
I have a JSP page with an application scope bean included (jsp:useBean).
This bean uses resources I need to free after the application gets restarted
by the manager.
The problem is, I have no idea how to do this. I've checked the docs, but I
must have overlooked it.
I suspected that the container might call some kinda destroy method, so I
tried all the usual ones, without result.
Do I have to explicitly remove it from the servlet context, or do I need to
write some method that the container can call?
Thanks for your time reading this.
nam3l3ss
Re: Application scope bean destruction?
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
nam3l3ss,
nam3l3ss wrote:
| I have a JSP page with an application scope bean included (jsp:useBean).
| This bean uses resources I need to free after the application gets
restarted
| by the manager.
| The problem is, I have no idea how to do this. I've checked the docs,
but I
| must have overlooked it.
See ServletContextListener. You're looking for contextDestroyed(), which
actually runs /before/ the context is destroyed in spite of its name.
You should be able to get any objects from the ServletContext
("application") and clean them up at that point.
| I suspected that the container might call some kinda destroy method, so I
| tried all the usual ones, without result.
Like what?
| Do I have to explicitly remove it from the servlet context, or do I
need to
| write some method that the container can call?
You write a class that implements ServletContextListener and configure
it as a <listener> in web.xml.
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkgQuJEACgkQ9CaO5/Lv0PCryQCfbRz84APv+LHzGHzbJUCbDGB0
deoAn05v/+To9WQ0Hm7IZ5TV2skfgRQh
=FhAP
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org