2 Answers - Sort by: Date | Rating
Constructor is a very important Concept for OOPS Generally it is used to Initialize the value into variabe. if u don't create constructor then it will be automatically created when object is created .
But init method is used for initialization, which means It initializes the local as well as global variable on server during using of post /get method with diff protocol used,The init method is generally used for Servlet as well as with JSP.
But init method is used for initialization, which means It initializes the local as well as global variable on server during using of post /get method with diff protocol used,The init method is generally used for Servlet as well as with JSP.
1
0
Constructor is a Java basic feature of Java.and Init method is designed in such a way that it acts as a constructor but it just a function which returns nothing and called by container not by the user.So constructor gets executed at any cost but init method should be called by the container after executing constructor normally.So instead writing the constructor it is better to write code in init() method which is also acts as constructor.
But in servlet when the Servlet instantiated by the container which means constructor called first then init method after calling the init method servlet is ready to accept the requests and those requests are processed thru service method.Once destroy method is called by the container the servlet is not available for serving the clients and for some web servers when a new user comes to the servlet it calls the init() method not the constructor...
Hope you understand the differences...
But in servlet when the Servlet instantiated by the container which means constructor called first then init method after calling the init method servlet is ready to accept the requests and those requests are processed thru service method.Once destroy method is called by the container the servlet is not available for serving the clients and for some web servers when a new user comes to the servlet it calls the init() method not the constructor...
Hope you understand the differences...
0
0
- What Is The Use Of Maths In Cs?
- How To Get Percentage Of Selling Price Product?
- What Is The Difference Between Selection Of The Principal Diagnosis For Inpatients Versus Outpatients?
- What The Least Common Multiple Of 24 And 36?
- Is There Third List?
- In Maths What Is The 3rd Decimal Of Pie?
- How To Make A Working Model In Maths Related To Daily Life?
- What Is Adjust Sale?
- What Is Adjustment Sale?
- The Results Are As Follows: Ethnic Group A: N = 15 M= 55 S2 = 6.5 Ethnic Group B : N = 23 M= 51 S2 = 4.5 If You Conduct A T Test For Independent Means, How Many Degrees Of Freedom Are In The T Distribution?
- What's It Mean When Someone Says To Get Marked Up?
- How Do Elasticity, Density And Temperature Effect The Speed Of Sound Through A Medium?
- What Are The Assumption For Plc?
- What Are The Name Of The Figures That Have 11-60sides?
- What Is The Importance Of Trigonometry In Real Life?
- When Was The First Ruler Invented?
- Two Dice Are Rolled. Find The Probability That The Score On The Dice Is Either 12 Or At Most 4?
- The Least Squares Line, Statistics Question?
- What Is The Greatest Common Factor Of 55 And 88?
- What Is The Difference Between Method And Methodology?
- What Is The Difference Between Abstract Class And Abstract Method?
- What Is The Difference Among Strategy,method And Techniques?
- What Is The Difference Between The V Model And Waterfall Method?
- What Is The Difference Between Wghtage Method And FIFO Method?
- What Are The Difference Between Deductive And Inductive Method?

New Comment - Comments are editable for 5 min.