Hello wise and learned folks. My question to you is: I am retrieving the name of the class (the servlet) by using getClass().getName() so that I can also have a URL to the source file available within the function of the servlet upon request. My question is does this method instantiate the class whose name it is trying to get? If it does thats not good business for the web container that I am using (especially since it's use is being lent to me for free). Its best to let the container handle the lifecycle of the servlet, other wise porblems may occur so I need to be wary of bad design. Anybody with some advise on that?
SCJ2P, IBM XML V1, Series 7/63
Joined: Aug 21, 2000
I am not sure I understand exactly what you mean. "getClass.getName()" itself does not instantiate an instance of the class whose name you are determining, but obviously you can only call "getClass()" on an existing object. If you are calling this in a servlet and your question is whether this creates another instance of the servlet, then the answer is no. "getClass()" creates a Class instance, but no instance of the servlet you call it on. -Mirko
Joined: Jan 23, 2001
Originally posted by Mirko Froehlich: If you are calling this in a servlet and your question is whether this creates another instance of the servlet, then the answer is no. "getClass()" creates a Class instance, but no instance of the servlet you call it on. -Mirko
That's exactly what I was asking. I justed wanted to be sure that I am not instantiating the servlet myself, on top of letting the container do it. Thanks for your help.