The processing of Mobile tariff page in J2ME network program

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.