Meaningless Drivel is fun!*
The moose likes Servlets and the fly likes Specfying TimeOut for a Request Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Specfying TimeOut for a Request" Watch "Specfying TimeOut for a Request" New topic
Author

Specfying TimeOut for a Request

RaviNada Kiran
Ranch Hand

Joined: Jan 30, 2009
Posts: 528

Hi ,

Is there anyway where i can specify Timeout for a request from a browser.

I am not sure whether the below is related for acheving this ??

response.sendError(response.SC_GATEWAY_TIMEOUT,
"Timeout");

If you want something you never had do something which you had never done
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

Please clarify what you are asking for.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Posts: 1374
Is there anyway where i can specify Timeout for a request from a browser.

I think you need Session TimeOut.You can specify it in Web Deployment Descriptor (web.xml).
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

When the browser sends a request, it will define a timeout period. If it has not received a response within that period, it will tell the user that.

You can't affect that timeout period, if that's what you are asking.
Alok Kushwah
Ranch Hand

Joined: Jul 10, 2007
Posts: 31
If scenario is as follows

- browser send request for some resource and wait for response.
- If browser get the response within x seconds display the resource.
- If browser does not get the response within x seconds display the timeout message.

Solution:

1. Open the page/resource in frame/iframe or use ajax
2. Use javascript function setTimeout("declare_timeout()",5000) for waiting for resource to download.
3. in declare_timeout() javascript function change url of frame/iframe to timeout page.
4. To clear the timout after page/source dowload use clearTimeout().

Notes: you can check some condition in step 3 to check dowload is completed before decalring timeout.

resource: http://www.w3schools.com/js/js_timing.asp
RaviNada Kiran
Ranch Hand

Joined: Jan 30, 2009
Posts: 528
Thanks Alok for your excellent explanation .

Thanks Paul.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Specfying TimeOut for a Request
 
Similar Threads
how to test destroy() in a servlet
Script/Request Timeout for JSP/Servlet?
Session Time out
Bad DNS, can't update Emacs+
Interview question asked to me which I could not answer