Tomcat Java Servlet - Initialize Class on Application Startup

后端 未结 3 1797
名媛妹妹
名媛妹妹 2020-12-30 09:01

I have a class that takes a bit of time to start up (makes some JNI calls and what not), so it is not feasable to initialize this class everytime a page loads. Is it possibl

3条回答
  •  囚心锁ツ
    2020-12-30 09:41

    You can do the initialize of the class inside the servlet's init method.
    init() method is invoked when the servlet instance is loaded so it is a good place for expensive operations.

提交回复
热议问题