Since the start of China Mobile Internet tariff page reminder, resulting in a lot of J2ME network has been linked to the server problem. That is, in the J2ME program to start networking, in some areas, sometimes, mobile gateway will be cut down our request, return a fee reminder page to us, so that our server will not receive our request, resulting in the program network failure error.
Therefore, when we are dealing with the network connection to add to the mobile Tariff page processing, we can send the network request, the return of the response HTTP header detection, if we detect the return of Content-type is text/ VND.WAP.WML, we can throw away this response, a new request can solve the problem of the tariff page, or we can extract the contribution fee page inside the request address, send a request again.
The code to process is as follows:
httpConn = (HttpConnection) Connector.open (url, permissions, true);
String s=httpConn.getHeaderField("Content-Type");
if(s.equals("text/vnd.wap.wml")){
//重新发起一次请求
httpConn = (HttpConnection) Connector.open (url, permissions, true);
}
If the program is going to return the type of WAP page, then we can the content of the WAP page keyword parsing to determine whether the server returned by their own pages or mobile return of the Tariff reminder page to be processed.