File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Interview question asked to me which I could not answer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Interview question asked to me which I could not answer" Watch "Interview question asked to me which I could not answer" New topic
Author

Interview question asked to me which I could not answer

Arjun Reddy
Ranch Hand

Joined: Nov 10, 2007
Posts: 627
Hi Guys,

Can we set request to be timedout? If so, where do we do it? Can we do it in web.xml declaratively or programatically in servelt? Or maybe in JSP? Need some help.

Thanks.


Be Humble... Be Nice.
arulk pillai
Author
Ranch Hand

Joined: May 31, 2007
Posts: 3219
Your Web container is the one spawning new threads to service the request. So, it should be a configuration in your container to timeout the thread. For example, in Webshere you can configure the thread pool size and the timeouts.


Java Interview Questions and Answers Blog | Amazon.com profile | Java Interview Books
Arjun Reddy
Ranch Hand

Joined: Nov 10, 2007
Posts: 627
Thanks Arulk for the reply. Can you tell me how to configure the thread pool size and the timeouts?
[ October 20, 2008: Message edited by: Arjun Reddy ]
Gopikrishna Madishetti
Greenhorn

Joined: Sep 30, 2008
Posts: 10
<session-config>
<session-timeout>120</session-timeout>
</session-config>


Thanks.
Sky Loi
Ranch Hand

Joined: Oct 06, 2008
Posts: 65
So far I know in Tomcat, there is server.xml config file. You could find the connectors section to config the thread pool and timeout. Hope it will help you.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18564
    
    8

Originally posted by Gopikrishna Madishetti:
<session-config>
<session-timeout>120</session-timeout>
</session-config>
That controls how long a session will be inactive before the container can invalidate it. The original question was "Can we set request to be timedout?" which has nothing to do with sessions.

I'm not sure what it would mean for a request to "time out". I wouldn't be surprised if a client (e.g. a browser) stopped waiting for a response after X seconds or minutes, but naturally that can't be controlled by the server in any way.
Sky Loi
Ranch Hand

Joined: Oct 06, 2008
Posts: 65
I agree with Paul. If the 'timeout' is meant in client side, you could define the timeout in client socket before you send request.
Adam Asham
Greenhorn

Joined: Jul 06, 2006
Posts: 13
Really, jsp/servlets don't have this? What about the servlet containers?
Asp.Net has this and even PHP offers script execution timeout at the backend. So what this means is that a request could potentially hang continuously until the container is restarted?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Interview question asked to me which I could not answer