aspose file tools*
The moose likes Servlets and the fly likes servlet timing out Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "servlet timing out" Watch "servlet timing out" New topic
Author

servlet timing out

rajesh mehra
Greenhorn

Joined: May 13, 2003
Posts: 4
Hi people,
I was working on a problem where I have to let the users know that their database query and/or session is going to timeout and they are going to get a "page not found" error.
What can I do in the servlet to capture that the page is not going to return and let the users know.
Thanks,
Rajesh
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12806
    
    5
You will have to run the database query or whatever the time consuming operation is in a separate Thread - presumably in something like a JavaBean that implements Runnable.
Keep in mind that servlets only respond to requests and can't just arbitrarily send a page.
Bill
rajesh mehra
Greenhorn

Joined: May 13, 2003
Posts: 4
Thank you,
I just needed a little more clarification. If I run the query in a seperate thread, then it will not time out and keep running in the background (say for half an hour) and in the meantime I can display to the user that his report is executing and he should wait.
I have an option where the user can get the web report by email too (am using a seperate thread).
So now that the web report never times out, the only thing I can do is to calculate the time at regular intervals and if it exceeds a certain time, display to the user that it is taking too long and maybe he should try email instead.
Please let me know if I am missing something.
Thank you,
Rajesh
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: servlet timing out