Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Script/Request Timeout for JSP/Servlet?  RSS feed

 
Bill Pearce
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anybody know of a way (either in servlet/jsp code or in the container configuration) to set the timeout property for the request? If there are any (former) ASP coders, this is like server.scripttimeout property.
Thanks.
Bill
 
Vlad Patryshev
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just out of curiosity - what is "request timeout"? I know page expiration time and session timeout; none of these seem to be what I think you think it should be...
 
Bill Pearce
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In ASP parlance, ScriptTimeout is a value (defaulted to 90 seconds) that indicates how long the server should process a script before giving up and terminating (sending a timeout message back to the client). This would be useful (for example) if the code entered an infinite loop due to some error. The server would cut off the processing at 90 seconds to keep from getting overloaded.
I am trying to figure out how to set the same for a JSP page. I have a page where users come to upload files. If the JSP engine os going to kill the processing after 90 seconds (or something similar), I would like to be able to extend that in order to give users on a slow link a little more time.
I am beginning to think that JSP/Servlets don't have this type of feature at all, since I am having such trouble finding one.
Bill
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds like what you're dealing with is a (ahem) feature that Microsoft cooked up to gracefully abort processing if it couldn't get done in time (as opposed to simply extending the lease time for a connection).
The timeout occurs in the user's web browser and there's nothing in the HTTP protocol to keep it from happening (I don't actually <i>think</i> http's specs ever address timing out on the client side). See, HTTP doesn't log on and keep a live connection - you send a request, you get a response. Send, response, Send, response. Short transactions, not a continuous execution. Each request stands alone (which is why we have these funny session thingies and such - it's the only way to ties all these apparently disconnected messagings together). The browser timeout is so the user gets control over the browser again if the server doesn't respond.
So why does IIS have a timeout and J2EE not? Because the pre .NET ASP pages have to be interpreted every time they're requested, and that takes extra time. JSP's only need to be compiled the first time, and servlets are precompiled from the start. Thus the Java server is expected to be able to respond in time.
Of course, there are lots of cases where this won't be so - mostly dealing with interactions to slower external processes or heavy calculating. If you <i>know</i> somthing's amiss, BTW, you can send back an SC_REQUEST_TIMEOUT status, but the servlet spec doesn't mandate that a servlet server externally terminate a servlet. Some servers may, but it's far better that you code in that kind of support rather than have it imposed on you.
As mentioned, you CAN'T simply send back a "wait-a-minute" message to the web client, since there is no such beastie. However, you can pass the work over to an asynchronous processor and return a "please wait" page. This page can be a simple "click here and I'll see if it's done" page or one that periodically resends itself (in effect doing the clicking for you). Once the asynchronous processor posts completion, you replace the "please wait" page with the results page, using the data returned by the asynchronous processor.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!