It's not a secret anymore!*
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
Author

JSP times out waiting CGI results

Theresa Radke
Greenhorn

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: 363
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
Rancher

Joined: Mar 22, 2000
Posts: 12681
    
    5
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.
Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP times out waiting CGI results
 
Similar Threads
JSP processing time without Network delay
Java CGI
whats the difference in CGI and servlets
Read Some 10,000 Files
Why is this bb written in cgi?