Skip to main content

Posts

Showing posts with the label request handling

Servlet Lifecycle Overview

Servlet Lifecycle Overview Servlet Lifecycle Overview The life cycle of a servlet can be categorized into four parts: Loading and Instantiation: The servlet container loads the servlet during startup or when the first request is made. The loading of the servlet depends on the <load-on-startup> attribute in the web.xml file. If <load-on-startup> has a positive value, the servlet is loaded with the container; otherwise, it loads when the first request is made. After loading, the container creates instances of the servlet. Initialization: After creating the instances, the servlet container calls the init() method and passes the servlet initialization parameters to it. The init() method must be called before the servlet can service any requests. Initialization parameters persist until the servlet is destroyed. The init() method is called only once t