Here's another question about a basic design choice (cfr. when to use Bean)

If you want some centralized components
(custom logging, database pool, custom user settings for security and
similar stuff,..)
you can use the servletContext or you can use a class with static methods or
a singleton class.
Currently I created my settings and dbpool objects as singletons. The most
important reason for that is that you need less code to call them. I know
myself, if it's too complex to use the dbpool, I'll start creating
workarounds anyway ;-)
If I had used the servletcontext, I would need something like

ServletContext thisContext = getServletContext();
SettingsHandler settings =
(SettingsHandler).thisContect.getAttribute("settings");
String tempPath = settings.getSetting("directory.temp");

Instead I do:

String tempPath = SettingsHandler.getSetting("directory.temp");

Since I use different JVM's for each project, things don't get mixed up. I
think that JServ uses a different ClassLoader for each servlet zone, so
these are separated as well.
The only thing is that I think the servlets and JSP pages will use each a
different instance and I cannot share instances over different machines when
I would use load balancing.
Any suggestions, remarks, other opinions?

Geert 'Darling' Van Damme

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to