Miles Daffin wrote:
> > >
> > > As long as this property value is never broadcast
> > > i.e. System.setProperty("myProperty", "42");
> > >
> >
> > System properties, in the sense that we are talking about the
> java.lang.System
> > class, are global to the entire JVM. Therefore, even if the statement
> above was
> > allowed, it would set the property "myProperty" for *all* web applications
> that
> > are installed in a single Tomcat instance, and would therefore cause a
> name
> > clash if another app also tried to set the value for "myProperty".
>
> Are such System calls prevented (intercepted somehow) in TC?
>
If you are running under JDK 1.1, they are prevented by the fact that JDK 1.1
does not have this method.
If you are running Tomcat 3.2 under a security manager, you can configure your
security policies to prevent this if you want to -- otherwise there is no
restriction.
>
> > Context parameters, on the other hand, are unique to an individual web
> > application so there are no problems with two web-apps having parameters
> (or
> > anything else, for that matter) with the same names.
>
> I shall use them from now on.
>
> <snip-paragraph: my suggestion>
>
> > You can use static variables for this purpose and get away with it, as
> long as
> > the classes involved are loaded from WEB-INF/classes or WEB-INF/lib. The
> reason
> > for this is that each web application is loaded by its own class loader,
> so
> > statics created by such classes are visible only within the web app. I
> have a
> > personal bias against statics (I prefer to store global application
> objects in
> > the servlet context, so that they are easily visible to all servlets and
> JSP
> > pages in my apps).
>
> Do you mean that you have a class, say Contants, that has a bunch of statics
> (public contants and maybe methods) that is only visible to objects in a
> particular
> app? In which case you are still using statics - only the scope has been
> narrowed,
> for obviously good reasons.
>
Let's say I have class com.mycompany.mypackage.MyClass that has a static method
foo(). Let's say that I install this class under WEB-INF/classes in two
different web apps.
In this scenario, there are two instances of MyClass in memory (even though they
have the same name), because they are loaded by two different class loaders.
The only way to have a static global across web apps in Tomcat is to put it on
the system classpath -- but beware: the ability to do this portably is *not*
guaranteed by the servlet spec.
>
> >
> > > Miles
> >
> > Craig
> >
> Miles
Craig