Hi guys,

> > From the looks of things, it is just the way it is, although I was
hoping
> > the there would be some way to put stuff in the web.xml file, maybe in
the
> > servlet tag like:
> >
> > <system-property>
> > <name>myproperty</name>
> > <value>42</value>
> > </system-property>
> >
> > Anyone think this is a good idea, or am I talking rubbish?
>
> It's a bad idea.  Keep your web-apps encapsulated.

Why would such a move, if it were possible, break encapsulation?

As long as this property value is never broadcast
i.e. System.setProperty("myProperty", "42");

If you want application local properties then simply create a class to hold
them
with a static method for obtaining them from anywhere in your app (like
System.getProperties()).

Have a Servlet initialize these by passing it the location of a properties
file containing the
props you need as an initialization parameter. This Servlet can be loaded on
startup,
load in the properties, and there you are, unless I have completely
misunderstood.

Check out the API for java.util.Properties#load(InputStream in)

>
> There is two ways to think about a "global" service:
> - providing a service to many servlets, seems like a good thing
> or
> - bleeding out dependencies upon those that don't need them and allowing
> access to those that shouldn't be using it.  bad things
>

What is 'bleeding out dependencies'? Please explain.

> > PS. static, bad?  It is useful! ...
>
> she said and meant _static initializers_ = bad, not static methods, and
> members.  I concur.

Why are static init blocks || methods bad?
Under what circumstances? In a Servlet context?

Please explain.

Miles

Reply via email to