Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP times out waiting CGI results

 
Theresa Radke
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic