File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet instance creation" Watch "Servlet instance creation" New topic

Servlet instance creation

Harikrishna Gorrepati
Ranch Hand

Joined: Sep 23, 2010
Posts: 423
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 | |
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63852

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] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Servlet instance creation
It's not a secret anymore!