This week's book giveaways are in the iOS and Features new in Java 8 forums.
We're giving away four copies each of Barcodes with iOS: Bringing together the digital and physical worlds and Core Java for the Impatient and have the authors on-line!
See this thread and this one for details.
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


Win a copy of Barcodes with iOS this week in the iOS forum
or Core Java for the Impatient in the Java 8 forum!

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: 629
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: 3319
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.


[500+ Java Interview Questions and Answers ] | [Java job hunting know how] | [Java resumes]
Arjun Reddy
Ranch Hand

Joined: Nov 10, 2007
Posts: 629
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: 19308
    
  10

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