Question

I am developing a Java ME Application. Here I am doing HttpConnection as follows,

HttpConnection httpConnection = (HttpConnection) Connector.open( url.trim() );

Variable url is an valid url. Sometimes because of unavailability of GPRS Connection, I am getting error in HttpConnection Error. So can I check that my HttpConnection is done or not ?

Was it helpful?

Solution

You can use the getResponseCode() & getResponseMessage() of HttpConnection's API for the checking of Successful Connection.

getResponseCode() will return integer value 200 which means it is successful connection with server. 404 means Page not found.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top