I read about bootstrapping here. How can I setup bootstrup file in my web application written with jsf,spring and hibernate.Is it necessary to setup bootstrup file in my application?
1 Answers
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.
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.
Basically, you have to create a class that implements javax.servlet.ServletContextListener
which has 2 methods, contextInitialized
and contextDestroyed
, that are executed when the application is started up, respectively shut down.
You must then add configure this class in web.xml, with something like that :
<listener>
<description>My Context listener</description>
<display-name>My Context listener</display-name>
<listener-class>
com.acme.myapp.MyContextListener
</listener-class>
</listener>
(Or in JEE6 you could use the javax.servlet.annotation.WebListener
annotation instead of XML)
Google is you friend for the details, but here are some links to start with :
http://www.roseindia.net/servlets/ServletContextListener-example.shtml

- 16,658
- 22
- 85
- 105