wood burning stoves*
The moose likes Sockets and Internet Protocols and the fly likes Problem while using HttpURLConnection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Problem while using HttpURLConnection " Watch "Problem while using HttpURLConnection " New topic

Problem while using HttpURLConnection

Rishi Tyagi
Ranch Hand

Joined: Feb 14, 2002
Posts: 100
Hi all,
i am using the folowing code to call a url in loop, but problem is
if url is not available in starting then it gives connect exception which should come: OK
Now once i have started the loop if in between the url link goes down then application hangs and it goes in wait for unlimited time to receive the response code of the response.
Now what i want to ask is : what is the reason behind this problem.
As par my knowledge it should throw the exception everytime if the link is down or not available .
If we call this code once only then it works fine but what happens in case we call the same code in a loop why it never throws any exception nor it comes out from the procesing.
Code starts here
URL urlS=new URL(urlStr);
HttpURLConnection httpConn=(HttpURLConnection)urlS.openConnection(); httpConn.setDoOutput(true);
int resp=httpConn.getResponseCode();
System.out.prinltn("Response Code :"+resp);
Code ends here
Rishi Tyagi
I agree. Here's the link: http://aspose.com/file-tools
subject: Problem while using HttpURLConnection
Similar Threads
Problems connecting to LDAP from Weblogic Server: BAD_CERTIFICATE error!
Web service using HttpURLConnection
Servlet design - static methods
How to get the HTTP Response code when a user has provided a invalid url.
How to persist the JSP produced output to a file without using the browser i.e I want