Unanswered: Monitoring a particular Table as soon as my Webserver(Application Server) is up.
Problem definition = I want to monitor a particular "table" in a database (MSSQLServer 2k or DB2 or Oracle8i) as soon as my Application Server(Weblogic 6.1 or Websphere ) is started.
The reason for monitoring is that, if some rows satisfy a particular condition then those rows have to be e-mailed to the concerned party.
I tried two possibilities
1)putting a <load-on-startup> tag, in my web.xml, and including my servlet's name which will perform the monitoring (the servlet instantiates an object of a class which extends Thread, and then calls the run() method).
NOTE:-- The run() method is in a while(true) loop, b'coz of continuous monitoring till the Appserver is closed.
2)Implented the "ServletContextListener " Interface and overridded the methods "contextInitialized(ServletContexEvent sce)" and "contextDestroyed(ServletContexEvent sce)".
The problem is that both the above methods serve the purpose of starting up the servlet and start the run() method of the Thread, but the Webserver(in my case Weblogic 6.1) does not entertain any other requests (for eg :-- not showing the Welcome Page) .
I think so the Webserver does not start properly and just in b/w of it's startup directly goes to execute the "startup servlet".
If I comment the line of "<load-on-startup>servletname</load-on-startup>" then the Webserver (Weblogic 6.1) starts up properly and entertains all requests.
Please suggest me any solution, by which I could achieve my task of monitoring that table as soon as AppServer get's started.
I am attaching three files, all combined into "Daemon.zip"
1)The servlet file which is called at "<load-on-startup>" or "implements ServletContextListener"
2)The class which extends Thread