• Post Reply Bookmark Topic Watch Topic
  • New Topic

java and servelt  RSS feed

 
bharath simha
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is diffrence between init() and constructor in java?
 
Amit KumarS
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi bharat,
both are more or less the same..but the difference lies in the way that it is used..
constructor are written in simple java classes.. but init() methods are written in servlets.
constructors are invoked whenever an object of that class is created.
where as when you deploy a servlet init() is called for the first time when that servlet is accessed and and rest of the times when severakl client try to access the same servlet only a new thread is spawned but the object is same.
this object is unloaded from memory only when server is shut down.
i hope you got the difference. if still in doubt then revert back
Bye
 
Malhar Barai
Author
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi..
Check this out..
hth
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!