Servlet init() Method
Learn Servlet init() Method (Servlet Lifecycle, JSP Servlets) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
What is init() Method? • The init() method is a lifecycle method of a servlet. • It is called only once. • It is called when the servlet is first loaded. • Used for initialization tasks. Why We Use init()? • Initialize database connection • Load configuration file • Initialize variables