Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Java web applications are "bootstrapped" by the web container in which they are run (e.g. Tomcat) and you don't have to do it yourself.</p> <p>However, if you want to add additional operations to be executed when the application is started up (and/or clean-up operations to be executed when the application is shut down), the servlet API provides the "context listener" mechanism.</p> <p>Basically, you have to create a class that implements <code>javax.servlet.ServletContextListener</code> which has 2 methods, <code>contextInitialized</code> and <code>contextDestroyed</code>, that are executed when the application is started up, respectively shut down.</p> <p>You must then add configure this class in web.xml, with something like that :</p> <pre><code>&lt;listener&gt; &lt;description&gt;My Context listener&lt;/description&gt; &lt;display-name&gt;My Context listener&lt;/display-name&gt; &lt;listener-class&gt; com.acme.myapp.MyContextListener &lt;/listener-class&gt; &lt;/listener&gt; </code></pre> <p>(Or in JEE6 you could use the <code>javax.servlet.annotation.WebListener</code> annotation instead of XML)</p> <p>Google is you friend for the details, but here are some links to start with :</p> <p><a href="http://www.roseindia.net/servlets/ServletContextListener-example.shtml" rel="nofollow">http://www.roseindia.net/servlets/ServletContextListener-example.shtml</a></p> <p><a href="http://docs.oracle.com/javaee/5/tutorial/doc/bnafi.html" rel="nofollow">http://docs.oracle.com/javaee/5/tutorial/doc/bnafi.html</a> </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload