How to create Servlet Instance

Servlet Instance Creation:

Following ways we can create instance of a servlet:
  • By default servlet instance will be created when first client will send the request to the servlet.
  • Only one instance will be created for one servlet and will be used to process all the request by using multiple thread.
  • If you want to create the instance while starting the server or container then you can use the follwoing:
  1.  In Web.xml
 <servlet>
                     ..................
<load-on-startup>I</load-on-startup>

</servlet>
// where I is int type value and it should not be negative.

 2.In Annotation 
              
  @WebServlet(....,loadOnStartup =I)



    
 

1 comment :

  1. Very awesome!!! When I seek for this I found this website at the top of all blogs in search engine.
    Locksmith Services in Las Vegas

    ReplyDelete