What will happen inside init() in servlet. my interviewer
asked servlet lifecycle. i said "once servlet is loaded in
to memory init() will be called which performs servlet
initialization " . Again interview asked what values will be
initialized . what is difference between init() and
init(ServletConfig config).

Answer Posted / manidhar

Your superclass includes two versions of init(),one that
takes a ServletConfig and a convenience version thats no -
arg. The3 inherited init(ServletConfig) method calls the no-
arg init method, so the only one u need to override is the
no-arg version.
no law that stops u from overriding the one that takes a
ServletConfig,but if u do then u better call super.init
(ServletConfig) but theres really NO reason why u need to
override the init(SC) method, since u can always get ur
ServletConfig by calling inherited getServletConfig()
method.
correct me if am wrong

Is This Answer Correct ?    3 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Define array. Tell me about 2-D array.

584


What is files manifesting?

1725


Can we overload the constructors?

555


What is java and its types?

549


What is the maximum size of array in java?

510






How does predicate work in java?

533


How would you convert bytes to string?

560


What is == and === in javascript?

553


How do you add an element to an arraylist in java?

483


Explain different types of thread priorities ?

623


Write a program to check string is palindrome without using loop?

563


enlist some features of jdk.

553


What are static blocks and static initalizers in java ?

582


How to restrict a member of a class from inheriting by its sub classes?

795


Why volatile is used in java?

527