File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes when the container instatiates the servlet will it Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Reply locked New topic
Author

when the container instatiates the servlet will it

sushindranath k
Greenhorn

Joined: Nov 30, 2006
Posts: 6
well,i want to know that when the container instatiates the servlet will it
calls a default constructor and if so of which
class constructor will it call is it HttpServlet/GenericServlet.

Regards
sushi
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

You're concentrating on the wrong thing. I don't think I have ever created a constructor for a servlet, or even worried about it.

The container instanitates the servlet, you don't worry about this.
The container initialises the servlet - this is where you come in.
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6657
    
    5

I would say three constructors ?

GenericServlet -> HttpServlet -> MyServlet

[EDIT]

I don't think I have ever created a constructor for a servlet, or even worried about it.


I agree. You could use the init method instead to instantiate whatever you want.
[ December 14, 2006: Message edited by: John Meyers ]

SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

Please do not ask the same question more than once. I am closing this instance of the topic.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: when the container instatiates the servlet will it
 
Similar Threads
Can i write a constructor in my servlet
Servlet's constructor
usage of servlet init() method and servlet constructor
in simple servlet ,why a constructor has super()?.
init() method in a Servlet's lifecycle.