I was going through this site and after reading it i had lot of doubts.Below are the doubts.
http://www.novocode.com/doc/servlet-essentials/chapter3.html
Below are the excerpts from that site
1)
doubt 1 Web servers load each servlet with a different class loader? why is that...we will have many servlets,so does that mean we will have that many class loaders?I always thought we had only one class loader and it will help us load the classes
doubt 2This is necessary to reload Servlets on the fly because single classes cannot be replaced in the running JVM. Only a ClassLoader object with all loaded classes can be replaced.
Above "doubt2" is not clear at all.
doubt 1A class literal FooServlet (as used in a type cast like "FooServlet foo = (FooServlet)context.getServlet("FooServlet")") which is used in class BarServlet is different from the class literal FooServlet as used in FooServlet itself.
I always thought class literal means or say formed by taking a type name and appending ".class"; for example, String.class
So why are two class literals different??
Thanks in advance....
http://www.novocode.com/doc/servlet-essentials/chapter3.html
Below are the excerpts from that site
1)
Note that in Java the identity of a class is not only defined by the class name but also by the ClassLoader by which it was loaded. Web servers usually load each Servlet with a different class loader. This is necessary to reload Servlets on the fly because single classes cannot be replaced in the running JVM. Only a ClassLoader object with all loaded classes can be replaced.
doubt 1 Web servers load each servlet with a different class loader? why is that...we will have many servlets,so does that mean we will have that many class loaders?I always thought we had only one class loader and it will help us load the classes
doubt 2This is necessary to reload Servlets on the fly because single classes cannot be replaced in the running JVM. Only a ClassLoader object with all loaded classes can be replaced.
Above "doubt2" is not clear at all.
This means that classes which are loaded by a Servlet class loader cannot be used for inter-Servlet communication. A class literal FooServlet (as used in a type cast like "FooServlet foo = (FooServlet)context.getServlet("FooServlet")") which is used in class BarServlet is different from the class literal FooServlet as used in FooServlet itself.
doubt 1A class literal FooServlet (as used in a type cast like "FooServlet foo = (FooServlet)context.getServlet("FooServlet")") which is used in class BarServlet is different from the class literal FooServlet as used in FooServlet itself.
I always thought class literal means or say formed by taking a type name and appending ".class"; for example, String.class
So why are two class literals different??
Thanks in advance....