Sharing is learning
Sharing is learning
No matter how much you know today, you will have to know more tomorrow.<br /> Hakunamatata !!!
Aapplication/web server maintains a pool of servlet instances for concurrent requests.But this pool consists of copy instances of ur servlet and is handled by javas reflection mechanism.
Chetan M
Aapplication/web server maintains a pool of servlet instances for concurrent requests.But this pool consists of copy instances of ur servlet and is handled by javas reflection mechanism.
Avi Abrami
The container is responsible for creating instances of your servlet/applet/EJB. It does this using java's reflection mechanism. So it assumes that your servlet/applet/EJB has a "default" constructor (a constructor that takes no arguments).
Originally posted by thomas davis:
1)I would like t know what is reflection mechanism and how ,when and where is it being used ?
The servlet container intializes the servlet by calling class.forName("serveltNameClass").newInstance().
2)What is the use above snippet in JAVA ?By calling class.forName() ?why are we initializing the class using newInstance() method?
3)Are there any functional similarities between this mechanism and singleton mechanism?
1)just with help of string (class name).
2)You do this whenenever yo dont know about the name of the class to be instantiated at the compile time.
Originally posted by thomas davis:
The two statements you provided seem to be contradictory.
First statements says, with the help of class name, class can be instantiated, but in the second statement, it says no need of knowing the exact name of the class for instantiating that particular class.
I could not comprehend these two statements, still I am not clear with significance of this mechanism (when is it being used)?
And this mechanism is being used for instantiating servlet class as well as Database Driver class..
I could understand this mechanism used for servlet for dynamically loading the class, but why is it being used for Driver class while connecting to database? Here, we are explicitly giving the Driver Name..Isn't?
In the case of servlet, container picks up the name of the servlet dynamically and instantiates the class.