Updates
  • Starting New Weekday Batch for Full Stack Java Development on 27 September 2025 @ 03:00 PM to 06:00 PM
  • Starting New Weekday Batch for MERN Stack Development on 29 September 2025 @ 04:00 PM to 06:00 PM

Servlet Instance Creation

• By default, the servlet instance will be created when the first client sends a request to the servlet.
• Only one instance will be created for one servlet and will be used to process all the requests by using multiple threads.
• If you want to create the instance while starting the server or container, you can use the following:

o In web.xml

<servlet>
….
<load-on-startup>X</load-on-startup>
</servlet>

o In Annotations

@WebServlet(….,loadOnStartup=x)

• Note: X will be an int type value. It should not be a negative integer.
• It indicates in which order the servlet instance will be created.