I completely agree. I only mentioned it for completeness, but you are very right that it is to be avoided in web apps. In the case of hot deploy on Tomcat that trick still works if the class is in WEB-INF/lib, but if you move it to the shared lib, you are in trouble. Good point.

Best regards,

-mb

 

 Richard Lewis-Shell <[EMAIL PROTECTED]> wrote:

I would recommend against using a singleton for application state - servlets
can be unloaded by their container, and singletons won't be - can lead to a
mess especially if your singleton is in a different jar/classloader from the
servlet.

Richard

----- Original Message -----
From: "Mind Bridge" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, October 22, 2002 8:57 PM
Subject: Re: [Tapestry-developer] Global References


>
> Just to add:
> In addition to what Malcom suggested, you can get the servlet context in
this way as well:
> cycle.getRequestContext().getServlet().getServletContext()
>
> and another approach is to use a singleton class outside the Servlet
hierarchy.
>
> Best regards,
>
> -mb
>



Do you Yahoo!?
Y! Web Hosting - Let the expert host your web site

Reply via email to