File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes instance of servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "instance of servlet" Watch "instance of servlet" New topic

instance of servlet

Arun Maalik
Ranch Hand

Joined: Oct 25, 2005
Posts: 216
Dear sir

I know that instance of servlet is created when init() method is called but in book of head first it has been written that init() method is called after creation of instance please specify these things.

Actualy what is the instance of a servlet ?


Arun kumar maalik
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63838

A method cannot be called on an instance of an object until after it has been created. So init() can't create the servlet instance, it is called by the container after the instance has been created.

[Asking smart questions] [About Bear] [Books by Bear]
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Servlets are no different.They are also like other java classes.
So you need to create instance before calling method init().

Rahul Bhattacharjee
LinkedIn - Blog
I agree. Here's the link:
subject: instance of servlet
It's not a secret anymore!