I have created a dynamic web project in eclipse. Now I have a situation in which I need to start a thread while application gets started[Short of in main method]. Now I searched the whole project for the class containing the main method. But I didn't get it.
Like in web.xml
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
Now I want to execute some code before index.jsp gets loaded.. Thanks in advance...
In general web applications are started from the application container and thus do not need to have a main method.
You may want to add a context listner so that you get notifyed about the start of the web application and where you can start your thread.
Here you can find an example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With