aspose file tools*
The moose likes Servlets and the fly likes in simple servlet ,why a constructor has super()?. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "in simple servlet ,why a constructor has super()?." Watch "in simple servlet ,why a constructor has super()?." New topic
Author

in simple servlet ,why a constructor has super()?.

jacob deiter
Ranch Hand

Joined: Apr 02, 2008
Posts: 576
in simple servlet ,why a constructor has super()?.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Because, Servlet must need to have default constructor[no-arg constructor]. Container use the default constructor to instantiate the servlet .
jacob deiter
Ranch Hand

Joined: Apr 02, 2008
Posts: 576
ok,then what the super() keyword does???

in some scenariop init method also contains super() ,then what it does here??
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

jacob deiter wrote:
in some scenariop init method also contains super() ,then what it does here??


Wrong . init() method doesnt have super() . super() calls the super class default constructor . compilar put the super() at the first statement of the constructor implicitly. you cant call super() from methods . but you can call super class method from your sub class method using super.methodSuper(). so you probably saw the super.init(config); from
public void init(ServletConfig config)

Hope This Helps
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: in simple servlet ,why a constructor has super()?.