It's not a secret anymore!
The moose likes Servlets and the fly likes basic question... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "basic question..." Watch "basic question..." New topic

basic question...

Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
why in init method..we need to call
super.init(config)? what is the use of this? When can we use it or skip it?
Aziz Ahmed

Joined: Sep 12, 2000
Posts: 2
If u want to initialize ur servlet to some default values ,while loading, u can use getInitParameter or similar methods found in ServletConfig. thats why u r initializing that. it is useful to establish Database connections.
Rahul Agarwal
Ranch Hand

Joined: Sep 13, 2000
Posts: 52
init() method is the first method which gets executed first so it is always better to place code here which u want to be executed first.database connections are such things
cata lin
Ranch Hand

Joined: May 11, 2000
Posts: 44
A servlet extends HttpServlet, which extends GenericServlet.
If you write a method called init(ServletConfig sc), you override the old method, and lose the work it was doing. By calling super.init(sc) you take advantage of it, and it's not you problem anymore to write code to properly init all the servlet.

[This message has been edited by cata lin (edited October 18, 2000).]
I agree. Here's the link:
subject: basic question...
It's not a secret anymore!