Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Methods of creating Servlet instance?

 
Vikrama Sanjeeva
Ranch Hand
Posts: 760
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
In how many ways one can create instance of Servlets?.
For e.g.
One method is to create instance in init() method, so when ever the server loads, a servlet instance will create.
I think there must be more methods.May be there is a method which creates instances when ever 1st request is made by client.
Bye.
Viki.
SCJP2
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't create a servlet instance. The server creates the servlet instance. The init method does not create your servlet instance -- instead it is called after it is created.
The instance is created by the framework in one of two ways, either on web container startup (as indicated by the "load-on-startup" tag) or upon first invocation by a client.
Kyle
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic