It's not a secret anymore!
The moose likes JSP and the fly likes Script Time Out Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Script Time Out" Watch "Script Time Out" New topic

Script Time Out

Shannon Sims
Ranch Hand

Joined: Jul 03, 2003
Posts: 197
I have page that requires a lot of data from the db, therefore the page times out. How does one set a page so that it does not time out before the data gets retrieved? Is there a setting on the response???
Any help is greatly appreciated!
Thank you!
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63858

Unless I miss my guess, it's the browser timing out. And I do not believe that there's a way to tell it to not do so, or to adjust the value from the server end.
Your best bet would be to design a UI that pages through the large dataset so that you are not sending so much data at a time. This will not only help your timeout problem, it's also just good UI. After all, is that much data really useful to your users? Or will it just overwhelm them?
The subject of paging datasets had been discussed in these forums many times. If you search for terms like "paging" in this forum, as well as possibly the Servlets, JDBC, and HTML forums I'm sure you'll find lots of helpful information.

[Asking smart questions] [About Bear] [Books by Bear]
Shannon Sims
Ranch Hand

Joined: Jul 03, 2003
Posts: 197
The large dataset isn't the problem, it's waiting for the data to return from the database. There is a link on a page that the user clicks to retrieve a report which can then be downloaded to the client. The problem is once they click on the link, a SQL statement is executed to retrieve the large dataset to be returned back to the calling page ( which cause the page time out). The normal behavior is that the report gets builted and zipped up and the user can then downloaded the file. Unfortunately, the large amount of data is needed.
Using ".asp" you can programmatically set a page from timing out using Server.ScriptTimeout = 180 (seconds). Isn't there a similar setting for .jsp pages?
Thank you.
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
Seems to me you should execute that SQL from a separate Thread - presumably in something like a Bean. Then your initial request can produce a response "Working"....
We have this sort of thing come up all the time, search the recent posts.
I suspect your ASP example is not changing the browser timeout.
toma lam

Joined: Aug 25, 2003
Posts: 4
Maybe you can also tweak the query a bit, or break it up to avoid the time out. If you're using SQL Server, it may execute faster if you put it all into a stored procedure; that is if you have several different queries happening to get your results.
Other database items to consider could be indexes.
Scott Duncan
Ranch Hand

Joined: Nov 01, 2002
Posts: 364
I do not understand how calling Server.ScriptTimeout will solve your problem. You need to retrieve a large amount of data in a specified amount of time. Otherwise, as already mentioned, the browser will time out. Also mentioned, there is no way to correct this safely without monkeying around with the browser config files and ultimately messing something up. Best bet is to kick off a thread and let it run it's course.

No more rhymes! I mean it!<br /> <br />Does anybody want a peanut?
Shannon Sims
Ranch Hand

Joined: Jul 03, 2003
Posts: 197
Thanks for everyone's replies. It looks like we (my team) have decided to leave it up to our DBAs to figure out how we can modify our store procedure to retreive the data more quickly.
Thanks again!!!
I agree. Here's the link:
subject: Script Time Out
It's not a secret anymore!