Charles Chen wrote:
>
> I believe someone (Christopher K?) has already answered this question that
> although in practice, this should be the case;
>
Actually, in both theory and practice different classloaders
will definitely be used to load the classes in different
servlet contexts.
> Why would Java do something like this? I wonder what is the reason
> behind this spec.....
>
Gogul Singh posted a reference to a paper on this:
<URL:http://www.javageeks.com/Papers/JavaStatics/index.html>
The idea is that if you've got two "web applications" they should
be independant of each other, even if they are running in the same
JVM.
Think about the case where an isp wants to run a single servlet
container for all the customers on a particular machine. There
are no guarantees that what one customer means by "myPackage.myClass"
is the same as what another customer means.
Even if it is the same class, then the class statics should not
be shared across web apps (if they are, the webapps might get a
nasty suprise)
Using different classloaders provides a "class sandbox".
There can be a special shared class sandbox, however, if the
servlet container supports it. That's an area where there are
a set of classes that all the servlet contexts can see and share.
Most of the time, though, classes in one servlet context should
be completely separate from classes in another servlet context,
and multiple classloaders let you do that.
-cks
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html