Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify Http Request timeout parameter on Java servlet container

I'm trying to understand where I can configure a request timeout for all requests arriving to a servlet of mine (or all of my servlets)? Is that, as I think, a container property? Also, how does this affect different browsers? Do they all comply to the parameter the container dictates? Or maybe the request timeout time isn't even something I can control and each browser decides on this on its own? (Just to be clear I'm not talking about session timeout)

like image 461
Ittai Avatar asked Sep 12 '09 10:09

Ittai


People also ask

How do I set HTTP request timeout?

Timeouts on http. request() takes a timeout option. Its documentation says: timeout <number> : A number specifying the socket timeout in milliseconds. This will set the timeout before the socket is connected.

How request parameters are stored for Java servlets?

For HTTP servlets, parameters are contained in the query string or posted form data. If the parameter data was sent in the request body, then i occurs with an HTTP POST request. Data from the query string and the post body are aggregated into the request parameter set.


2 Answers

The timeout from a client (i.e. how long it waits for a response to an HTTP request) is determined at the client. For IE, see this, and for Firefox see this.

You can't control this timeout from the server.

like image 112
Vinay Sajip Avatar answered Sep 22 '22 19:09

Vinay Sajip


Even though you can't control client timeout, you can make server very impatient :) For example, on Tomcat, you can do this in your connector,

<Connector port="8080"  
  ...
  connectionTimeout ="5000"
  disableUploadTimeout="false" />

This makes server only wait 5 seconds and close the connection. Browser will get a connection closed error. You can treat it the same as timeout in client.

Of course, this only works if the timeout is caused by the server, not connectivity issues between browser and server.

like image 40
ZZ Coder Avatar answered Sep 25 '22 19:09

ZZ Coder