permaculture playing cards*
The moose likes Servlets and the fly likes Servlet instance creation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet instance creation" Watch "Servlet instance creation" New topic
Author

Servlet instance creation

Harikrishna Gorrepati
Ranch Hand

Joined: Sep 23, 2010
Posts: 422
Hi, How Servlet container will create Servlet instance..I read the following ways in the net but not sure which one is right

1. Container use any Reflection API.
2. Container calls class.forName(classname).newInstance()
3. Container calls init() method


OCPJP 6.0-81% | Preparing for OCWCD
http://www.certpal.com/blogs/cert-articles | http://sites.google.com/site/mostlyjava/scwcd |
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60789
    
  65

The container can create an instance any way that it wants to -- the Specification doesn't mandate any particular way.

After the servlet instance is created, its init() life-cycle method will be called regardless of how the container has chosen to perform the instantiation. This is not a means by which instantiation happens, but something that occurs after instantiation.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Servlet instance creation
 
Similar Threads
Servlet Container
init() called at the same time
How Servlet Container creates an instance of your Servlet
Servlet Life Cycle-Destroy method
Why using init() method