The type of exception thrown can depend on the library used for making the server request. If you're using the java.net package's HttpURLConnection, the typical exception to be thrown is a java.net.SocketTimeoutException when a read or accept times out.
If you're using a library such as Apache HttpComponents, OkHttp, or Spring's RestTemplate, the exceptions thrown may differ, but they will often wrap the underlying SocketTimeoutException.
In the case of Apache HttpComponents, the exception will be a org.apache.http.conn.ConnectTimeoutException if the connection times out, or org.apache.http.conn.SocketTimeoutException for a socket timeout.
If you're using OkHttp, a timeout will result in a java.net.SocketTimeoutException being thrown.
If you're using Spring's RestTemplate, a org.springframework.web.client.ResourceAccessException may be thrown, wrapping the underlying SocketTimeoutException.
Note that in all these cases, you'll want to handle not just timeouts but also general IOException cases that can occur due to network errors.