It's true that the ServletContext seems a better place to store the global
settings.
But a singleton class has the big advantage that it can be called from any
class, not just from within a servlet or JSP. If you have several
applications in one JVM you'll have to find another way to separate the
settings for them e.g. with a prefix for each application.
Geert 'Darling' Van Damme
> -----Original Message-----
> From: A mailing list about Java Server Pages specification and reference
> [mailto:[EMAIL PROTECTED]]On Behalf Of Tim Fox
> Sent: woensdag 2 februari 2000 19:12
> To: [EMAIL PROTECTED]
> Subject: Re: Global Properties
>
>
> Be careful though using patterns (eg Singleton) that utilise
> class scope (ie statics)
> in a servlet engine.
>
> The class scope is exposed to everything in that instance of the
> JVM, whereas a single
> JVM can host multiple web applications.
>
> So, if you do end up wanting to host two different instances of
> your web app (in
> different contexts) in the same JVM, then you're going to have
> problems if your using
> a Singleton.
>
> If you want some configuration accessible to all servlets (etc)
> in a particular web
> application (I think that's what you're looking for) then it's
> probably better to use
> the ServletContext as a dumping ground for your shared stuff.
>
> That's my 2p anyway.
>
> > You don't need to rely on the servlet engine for this, and you certainly
> > don't need to hard-code these values in any of your classes. You should
> > implement a singleton design pattern "properties" class that loads
> > itself with information from a .properties file -- a fairly simple
> > wrapper around java.util.PropertyResourceBundle.
>
> ==================================================================
> =========
> 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
>
>
===========================================================================
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