Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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).

Answers were Sorted based on User's Feedback



What will happen inside init() in servlet. my interviewer asked servlet lifecycle. i said "on..

Answer / amit singh

when the first request goes to the container then first
container create the object and the constructor execute
then init() method called
note: thatGenericServlet has an
init(ServletConfig conf ) method require by the Servlet
interface. If you don't override init(ServletConfig conf),
then the GenericServlet method will be called - it in turn
calls the init() method.
so if you use the override the init(ServletConfig con)
so you should to call the super.init(ServletConfig con)
which in turn call the lnlt()
2)what will happen inside the init() its use to intialize
teh parametr which you give in a web.xml
so it intialize the custom parmeter and other paranetr too
so its just for intialization
because wedon't do intialization through constructor
bracuse the object of servlet will create by webcontainer
and execution of constructor too so we use thr init method
for initializtion because we are not able to use new for
creating a object in sevlet
thanks amit singh

amitsing2008@gmail.com

Is This Answer Correct ?    8 Yes 1 No

What will happen inside init() in servlet. my interviewer asked servlet lifecycle. i said "on..

Answer / 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

More Core Java Interview Questions

What is the difference between JDBC 1.0 and JDBC 2.0?

0 Answers   Corent Technology,


what is the Yield() method used in threads?

4 Answers   Accenture,


What does n mean in java?

0 Answers  


What is the role of the java.rmi.naming class?

0 Answers  


Explain the pointers in Java?

0 Answers   Aspire,


How use .contains in java?

0 Answers  


What is the difference between double and float variables in java?

0 Answers  


What are the four pillars of java?

0 Answers  


What are keywords and reserved words in java?

0 Answers  


what are depricated methods ?

5 Answers   Satyam,


What is meant by class loader? How many types are there? When will we use them?

0 Answers  


What is the difference between final, finally and finalize()?

0 Answers  


Categories