Hi all, I am a newbie programmer and i want to make a database of reminders which a user can enter through an html page and at the appointed time a pop up window will come reminding the user. i plan to use POSTGRESQL for database and jdbc to connect and plan to run the servlet on a tomcat.now my biggest problem is how can i keep track of the times in the database and act when the time is come.... regards
OK, first the database part. You can set up a timer that runs every five minutes that does a query on the database where the time is within the next five minutes, and what you get back you loop through and create your reminders.
Now getting the reminders to popup is another question that I don't think I can answer because of the request-response nature of Servlets and the web. I don't think that on the server-side you can start such a process. Plus how do you know the user has their browser up to get the pop-up.
You could write a simple client app that is a stay resident type program that can receive messages. You can still have the web app for entry.
In a rather sophisticated solution, we have an applet that registers with the server when it's started. It opens a ServerSocket and gives the server a userid, ip address and port. When the server decides to send a message to a user, it checks to see if the userid is registered. If so, it can talk right to that port and send data; the applet pops a window to show it to them. If the userid is not registered the server saves the message and the user queries for old messages next time they log on. This probably requires a distributed cache in a clustered system.
The other part of the story is how does the server know it's time to send something? We use a commercial timer package called Flux but I think one called Quartz is open source. Flux can persist timers to a database so they survive restarting or crashing the server, and Flux works in clusters so only one server tries to handle the timer event.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Joined: Nov 13, 2002
Hi, We have one system that's similar to the one suggested by Stan James above. However, please note the above solution requires some care. In particular, "unsigned applets can only phone home", meaning you have to either put a digital signature on you applet, or make sure it's deployed on the exact same location as you servelt (admittedly i've never tried the latter).
For simple cases, i'd go with the "meta refresh" solution, although it offers much less sophistication & flexibility.