Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can You please differentiate in ser

Status
Not open for further replies.

jutla

Programmer
Jul 14, 2002
6
0
0
IN
Can You please differentiate in servlets
What is the difference between init(),init(ServletConfig config){super.init(config);}

In init() why we should not call super.init(config)?
 
Hi,

From the Javadocs:

<<<
public void init() throws ServletException

A convenience method which can be overridden so that
there's no need to call super.init(config).

Instead of overriding init(ServletConfig), simply override
this method and it will be called by
GenericServlet.init(ServletConfig config). The ServletConfig
object can still be retrieved via getServletConfig().
>>>

In other words, you can write your own
MyServlet.init() method, that will override the init()
method in GenericServlet and it will be called by GenericServlet.init(ServletConfig config). If you
decide to override init(ServletConfig config) instead,
then you should call super.init(config).

Again, from the Javadocs:

<<<
public void init(ServletConfig config)
throws ServletException

Called by the servlet container to indicate to a servlet
that the servlet is being placed into service. See
Servlet.init(javax.servlet.ServletConfig).

This implementation stores the ServletConfig object it
receives from the servlet container for alter use. When
overriding this form of the method, call super.init(config).

Specified by: init in interface Servlet

Parameters:
config - the ServletConfig object that contains configutation
information for this servlet
Throws:
ServletException - if an exception occurs that interrupts
the servlet's normal operation
See Also: UnavailableException
>>>

HTH,
Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top