I found a solution, Here it is for those who are interested:
int resCode; String location = "http://company.com/temp1.aspx"; while (true) { HttpConnection connection = (HttpConnection) Connector.open(location + ";deviceside=true"); connection.setRequestMethod(HttpConnection.GET); connection.setRequestProperty(HttpHeaders.HEADER_CONNECTION, "close"); connection.setRequestProperty(HttpHeaders.HEADER_CONTENT_LENGTH, "0"); resCode = connection.getResponseCode(); if( resCode == HttpConnection.HTTP_TEMP_REDIRECT || resCode == HttpConnection.HTTP_MOVED_TEMP || resCode == HttpConnection.HTTP_MOVED_PERM ) { location = connection.getHeaderField("location").trim(); } else { resCode = connection.getResponseCode(); break; } }
source share