jQuery in Action, 3rd edition
The moose likes JSP and the fly likes JSP times out waiting CGI results Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP times out waiting CGI results" Watch "JSP times out waiting CGI results" New topic

JSP times out waiting CGI results

Theresa Radke

Joined: Jul 18, 2003
Posts: 1
I have a JSP that gathers form data and submits it to a perl program in a CGI bin. This perl program calls a server side executable and does some processing that can take a long time at times. My problem is that if the request requires a lenthy processing time the JSP page times out waiting for the response from the Perl Program.
Any suggestions about how to force the JSP to wait?
Scott Duncan
Ranch Hand

Joined: Nov 01, 2002
Posts: 364
What is timing out is your browser and unfortunately, although possible, it is not plausible to change the timeout settings on it.
One sloppy 'workaround' that I would suggest is to create a thread and kick it off in the servlet and redirect to a 'waiting' page. In the thread object, store a boolean that will be set to true when the thread has finished executing. After kicking this off, store it into the session. Set your 'waiting' page to refresh every minute or so. When it does have it hit the servlet and pull the Thread object out of the session and check the value of the boolean. If it's true, send the data back to the user, otherwise redirect back to the 'waiting' page. As I said, this is sloppy but is the best I can offer at 10:36 on a Friday night.

No more rhymes! I mean it!<br /> <br />Does anybody want a peanut?
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
A separate helper object that runs its own Thread is really the best solution. After you create it and start it running, just put it in the session. Make sure you provide some way for it to communicate status.
One great advantage of putting all the work in a helper object is that you can test it off-line - without the additional confusion of JSP.
I agree. Here's the link: http://aspose.com/file-tools
subject: JSP times out waiting CGI results
It's not a secret anymore!