esuslogo
 [To advertise Java(tm) Events here, contact joris@esus.com!]
banner

Java™
by example!






New @ Esus.com


  gb  In-house search engine for better results!

  gb  Get updates with the esus.com
newsletter!









  Home 
 Browse Categories 
 Ask a Java Question 
 Help 
  For Java Tips & Tricks, subscribe to the esus.com newsletter!
Search Java Q&A, Links, API's:   adv 

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:

This code sample is only viewable to esus.com members
Login or become a member!



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:

This code sample is only viewable to esus.com members
Login or become a member!




Further Information
Author of answer: Joris Van den Bogaert

Comments to this answer are only viewable by members. Login or become a member!





Terms of Service | Privacy Policy | Contact

Copyright © 2000-2003 Esus.com - All Rights Reserved 
Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. Esus.com is independent of Sun Microsystems, Inc. All other trademarks are the sole property of their respective owners.