HttpResponse 302 Code

I am using the BB 8900 simulator. I am trying to connect to the url and get the response code 302. What does this mean? Here is my code snippet:

import javax.microedition.io.Connector;
import javax.microedition.io.HttpConnection;
.....
connection = (HttpConnection)Connector.open(url);
responseCode = connection.getResponseCode();
+3
source share
1 answer

HTTP 302 is a temporary redirect . You need to handle this.

According to the standard, if you receive a 302 response, the response will contain a Location header field with a redirect:

Client request:
GET /index.html HTTP/1.1
Host: www.example.com

Server response:
HTTP/1.1 302 Found
Location: http://www.redirected-address.example.com/

You need to extract the new URL from the response. (Use getHeaderField("Location")to do this). Then follow the same method at the new URL that you received.

Two other points:

  • , URL. , 302, URL- "".

  • GET HEAD, . . RFC .

+8

All Articles