Hi I have a servlet that accesses a MS SQL DB.. It accesses lots of data so it takes a lot of time to finish, about 15 minutes, which is normal.
Now under normal Servlet execution,if i run this servlet, the web browser will be left blank until the process ends. So is there a way or approach to notify the client as to whether this process is in process or has finished? [ December 19, 2005: Message edited by: Bear Bibeault ]
Can u send me the code? are u using ServletContextListener? ServletContextListener will notified when ever application is deployed. this listener will be called before any servlets or JSP. u can very well store Database connection inf in the attributes so that other servlets or jsp's in your webapplication can make use of it.
If the process is going to take a long time, (more that 15 or 30 seconds), I like to start it in a separate thread and return the user to a status page immediately. In the status page I have a meta refresh tag that will cause it to refresh every n seconds. Each time it refreshes, it checks on the status. Once the process is done the status page redirects to the completed report. The user should be able to leave the application and come back without interrupting the process.
If the report will take longer than a minute or two, it's also a nice idea to have it email the user when it's done so they don't have to keep checking back for a status.
As Clarke did mention that it is taking about 15 minutes, it is really a long time to make user keep-on-waiting. As Ben said, it is better to just notify the user over email or have users to goto a page to check the status when they wish (after approx 15 minutes). This would save lots of server resources.