View Single Post
Old 03-17-2011, 12:25 PM   #6
xmncxzvt
Thumbs Must Hurt
 
Join Date: Mar 2011
Model: 8900
PIN: N/A
Carrier: Torch
Posts: 59
Thumbs up Re: Https Connection

Thanks Dougsg38p
I got your suggestion
This means that
String location =httpConnection.getHeaderField("Location"); gives redirected url.
Some sites provide their url which redirects to another url (actual url) or we
can say that some sites doesnt gave direct access to their url.So, we are
accessing those sites indirectly.when we enter url in browser it automatically access redirected url & opens page but in code when we create httpconnection & gave it in url, it doesnt automatically opens redirected url.

So, we get redirected url from getHeaderField() , create another httpconnection object & gave it redirected url like this:

HttpsConnection httpconn = null;
HttpsConnection hc = null;
InputStream is = null;


httpConn = (HttpsConnection) Connector.open(url);
httpConn.setRequestMethod(HttpsConnection.POST);

String location =httpConn.getHeaderField("Location");

hc = (HttpsConnection) Connector.open(location);
is = hc.openDataInputStream();

I havent implemented this change to my code yet. But I think now response
code must be 200 because i am creating another httpconnection object &
giving it redirected url.

Let me make this change to my code
Offline   Reply With Quote