|
Java™ by example!
|
|
|
How do I start a Servlet automatically at startup?
You can have a servlet automatically startup when the Tomcat (or other) server starts. This is useful for example in case you would like to start a connection pool servlet. Modify the web.xml file that describes your servlet and include a tag called load-on-startup. The contents of this tag must be a positive integer indicating the order in which the servlet should be loaded. Lower integers are loaded before higher integers. For example:
Start up your server and check the logs. In Tomcat, logs/servlet.log shows a call the the init method that you can override in your servlet:
Further Information
Author of answer: Joris Van den Bogaert
Comments to this answer are only viewable by members. Login or become a member!
|
|
|
|
|