How do I load a class at startup in a tomcat? See load-on-startup tag for the web.xml file, but can I use it and how should I write my class?
EDIT: OK, but how can I apply this class and XML is correct?
& lt; Servlet-name & gt; & Lt; / Servlet-name & gt; & Lt; Servlet category & gt; ?? & Lt; / Servlet category & gt; & Lt; Load-On-Startup & gt; 10 & lt; / Load-on-startup & gt;
These servlets are meant to specify the loading order, however, at the start of weblet When you prefer sound to seek hooks, servicelets are for HTTP requests / reactions for more control, preprocess and / or postprocess In that case, you want a ServletContextListener .
@WebListener public class configuration applies: ServletContextListener {public void contextInitialized (ServletContextEvent event) {// Make Your Talk During Webapp To Be On } Public Zero Context deleted (ServletContextEvent event) {// Talk to you while webapp is being closed}} If you are still not on Servlet 3.0 (and so on < Code> @WebListener ), then you have to manually Web.xml as follows:
& lt; Listener & gt; & Lt; Audience category & gt; Com.example.Config & lt; / Listener Category & gt; & Lt; / Listener & gt;
Comments
Post a Comment