aspose file tools*
The moose likes Servlets and the fly likes How to implement Request Time Out Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to implement Request Time Out" Watch "How to implement Request Time Out" New topic
Author

How to implement Request Time Out

shashi wagh
Ranch Hand

Joined: Oct 30, 2008
Posts: 38
How to implement Request Time Out in Web Application?

If request doesn't respond in 30Sec system should show Request Time Out Page.




How do I implement the same?
Srikanth Nutigattu
Ranch Hand

Joined: Oct 30, 2007
Posts: 114
Are you talking about Session timout?

If yes, you can configure using


or you can specify by calling public void setMaxInactiveInterval(int interval) of HttpSession classhttp://java.sun.com/products/servlet/2.2/javadoc/

The difference between the two is using the xml approach you can specify in minutes where as using the API you can set session timeout in seconds.
Harpreet Singh janda
Ranch Hand

Joined: Jan 14, 2010
Posts: 317

You can configure a listener which will check for the session and redirect to error page if session is null;
shashi wagh
Ranch Hand

Joined: Oct 30, 2008
Posts: 38
I know about the Session Time Out. n web.xml setting n all



I want to Implement Request Time Out.......


Say I put request http://localhost:8080/HRMS/GetEmployee.do Servlet

It will hit the server and shows the Response on the browser.
I want the request should process within the specifies time Say 1 Sec.

If it takes more than 1 Sec. It should redirect to Some other page showing the Request Time is Out


Harpreet Singh janda
Ranch Hand

Joined: Jan 14, 2010
Posts: 317

You can use javascript which will start counting when a page is loaded and will redirect to a url as soon as the counting is over.
shashi wagh
Ranch Hand

Joined: Oct 30, 2008
Posts: 38
Can you explain more how do I achieve the same using Javascript?

Sample Code or URL?
shashi wagh
Ranch Hand

Joined: Oct 30, 2008
Posts: 38
I have Develop following Login
But It shows the Time out page After processing the request i.e. after 4 Sec.

I want to halt the Request Processing in 1 Sec.

Filter Code

--------------------------------------------------------------------------------------------------------
Timer


I have also tried



------------------------------------------------------------------------------------------------------------------------------
Next Jsp

----------------------------------------------------------------------------------------------------
Result on Consol
Anky Singhal
Greenhorn

Joined: May 16, 2011
Posts: 1
shashi wagh wrote:I have Develop following Login
But It shows the Time out page After processing the request i.e. after 4 Sec.

I want to halt the Request Processing in 1 Sec.

Filter Code

--------------------------------------------------------------------------------------------------------
Timer


I have also tried



------------------------------------------------------------------------------------------------------------------------------
Next Jsp

----------------------------------------------------------------------------------------------------
Result on Consol


Dear Sashi,

Is this code working at your end? Actually m also looking out a soln for similar prob. I am not able to call that error.jsp from request time listener class.
Souvvik Basu
Ranch Hand

Joined: Apr 05, 2010
Posts: 96
You can try using this one. This isnt exactly what you want, but something similar. Clicking on a button takes you to another page. Here you have another button. You either click it within a certain time interval, or you get timed out and sent to a different page.
Hope this helps you.

I'll just give you the relevant servlet code. The rest (mapping, jsp etc) should be easy.



showsessiontime.jsp


timedout.jsp

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to implement Request Time Out