init() method in servlet – Education Career Blog

can we change the name of the init() method of servlet?
i mean to say the life should be-
xyz()-service()-destroy()
instead of
init()-service()-destroy()

,

No. init() is a method defined in the servlet base class – if you use a different method name, you won’t be overriding an existing method.

You could write an init() method which just calls xyz() of course – and do so in a base class used by all your servlets. It doesn’t seem like a great idea though – why would you want to do this in the first place?

Leave a Comment