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/06/05 11:02:00 UTC
Get bean from servletContext on context destruction
Hy!
I have a bean on a jsp page (jsp:UseBean) , with application scope, that uses
some resources that must be freed when the application is stopped/reset.
I'm currently using a context listener to detect when does the servelt context
gets destroyed, but I cannot get the bean from it.
What I want to accomplish is:
1:public void contextDestroyed(ServletContextEvent e){
2: ServletContext t = e.getServletContext();
3: myBean b =(myBean)t.getAttribute("newsbean");
4: if(b!=null){
5: System.out.println("Bean is:" +(b.holdsResource() ? "!ok" : "ok"));
6: }else{
7: System.out.println("No bean =(");
8: }
9:}
where line 3 should do the trick. How can this be done?
Googling only turned up the reverse, accessing context from a bean,
and the listener is by the webapp in web.xml.
Thanks, nam3l3ss
---------------------------------------------------------------------
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
Re: Get bean from servletContext on context destruction
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Nameless,
Nam3l3ss wrote:
| I have a bean on a jsp page (jsp:UseBean) , with application scope,
that uses
| some resources that must be freed when the application is stopped/reset.
|
| I'm currently using a context listener to detect when does the servelt
context
| gets destroyed, but I cannot get the bean from it.
When are you putting the bean into the context in the first place?
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkhO5KIACgkQ9CaO5/Lv0PCkiQCfQOK5eNN5d0DnLx8rvYyu2qxu
HB8An3xuleWHItgDxymG35BLMRv+EhFw
=sK66
-----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