Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

optimize java.net.HttpUrlConnection.getResponseCode()

843790Aug 3 2006 — edited Aug 7 2006
We have a healthcheck page in a web application, which is accessed by various tools to check whether the application is running normally. This page has to load fast, within 100ms.

Now, in the servlet code, we hit another application's healthcheck page like this:
HttpURLConnection myConn = (HttpURLConnection) myUrl.openConnection();
if (myConn .getResponseCode() != HttpServletResponse.SC_OK)
{
...
}
Now, getResponseCode() seems to be taking a long time (~500 to 1000ms).
On profiling with NetBeans, we found out that internally java.net.SocketInputStream.read(byte[], int, int) is taking all the time.

Any idea on how to optimize?
All comments, suggestions, etc are welcome!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 4 2006
Added on Aug 3 2006
3 comments
310 views