Thanks for the reply. This is exactly what I had in mind. However, I did not want to use the synchronized keyword. In my case, my "someBean" object is just a delegate that passes data transfer objects to and from the back-end. So, I'm wondering if I really need to use the synchronized keyword.
--- On Sun, 6/14/09, Jonathan Mast <jhmast.develo...@gmail.com> wrote: From: Jonathan Mast <jhmast.develo...@gmail.com> Subject: Re: using static helper classes within servlets To: "Tomcat Users List" <users@tomcat.apache.org> Date: Sunday, June 14, 2009, 1:01 PM I've not done anything with EJBs and I'm not sure what exactly you mean by static "properties". I have however dealt with reducing instantiations in servlets. I simply created a BeanBag class with static methods to each one of my beans; these are not "proper" beans, but where simply objects that were formerly used in JSP via the jsp:useBean directive. Here is the general pattern: class BeanBag { private static SomeBean someBean = null; public static synchronized getSomeBean() { if (someBean == null) someBean = new SomeBean(); return someBean; } } I have now numerous Servlets, JSPs and POJOs that use BeanBag to obtain singleton instances of my beans. Its worked great for me. On Sun, Jun 14, 2009 at 8:28 AM, Sid Sidney <pvcsv...@yahoo.com> wrote: > > > > HI, > > > > In my web app, my servlets user several delegate classes that connect > to ejbs (session beans.) I was thinking > about putting these delegates into a helper class as static properties. > That way my servlets can just reference the same delegates. I > don't want to have to create a new instance of a delegate with every > request that my servlet(s) handles. > > > > However, I'm wondering if this will cause synchronization issues with > multiple requests being handled, as our site handles a heavy load of > requests. Any suggestions would be appreciated? > > >