Is there a means of executing code during the startup of Apache Tomcat 6.x to perform initialization routines, etc.?

后端 未结 2 540
感情败类
感情败类 2021-01-04 10:39

I want to initialize a global instance of a class before my Tomcat server completes startup and begins to offer my servlets. If this service somehow fails initialization, I

2条回答
  •  一个人的身影
    2021-01-04 11:14

    One thing you can do portably is to implement a servlet that initializes everything you need in its init() method (and maybe call System.exit() if it fails, i do not know if you have permission to do this in Tomcat). Then you would load it using in your web.xml to specify initialization order.

提交回复
热议问题