麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 學院 > 開發設計 > 正文

調用 CGI 腳本

2019-11-18 16:05:46
字體:
來源:轉載
供稿:網友
/*
Learning Wireless java
Help for New J2ME Developers
By Qusay Mahmoud
ISBN: 0-596-00243-2

*/
import java.io.*;
import javax.microedition.io.*;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;

/**
 * An example MIDlet to invoke a CGI script (POST method is used).
 */

public class InvokeCgiMidlet2 extends MIDlet {

   PRivate Display display;

   String url = "http://www.javacourses.com/cgi-bin/pgrade.cgi";

   public InvokeCgiMidlet2() {
      display = Display.getDisplay(this);
   }

   /**
    * Initialization. Invoked when we activate the MIDlet.
    */
   public void startApp() {
      try {
         getGrade(url);
      } catch (IOException e) {
         System.out.println("IOException " + e);
         e.printStackTrace();
      }
   }

   /**
    * Pause, discontinue ....
    */
   public void pauseApp() {
   }

   /**
    * Destroy must cleanup everything.
    */
   public void destroyApp(boolean unconditional) {
   }

   /**
    * Retrieve a grade....
    */

   void getGrade(String url) throws IOException {
      HttpConnection c = null;
      InputStream is = null;
      OutputStream os = null;
      StringBuffer b = new StringBuffer();
      TextBox t = null;
      try {
         c = (HttpConnection)Connector.open(url);
         c.setRequestMethod(HttpConnection.POST);
         c.setRequestProperty("CONTENT-TYPE","application/x-www-form-urlencoded");
         c.setRequestProperty("User-Agent","Profile/MIDP-1.0 Confirguration/CLDC-1.0");
         c.setRequestProperty("Content-Language", "en-CA");
         os = c.openOutputStream();

         // send input
         String str = "name=182016";
         byte postmsg[] = str.getBytes();
         for(int i=0;i<postmsg.length;i++) {
            os.write(postmsg[i]);
         }
         os.flush();
         is = c.openDataInputStream();
         int ch;
         // receive output
         while ((ch = is.read()) != -1) {
            b.append((char) ch);
            System.out.println((char)ch);
         }
         t = new TextBox("Final Grades", b.toString(), 1024, 0);
      } finally {
         if(is!= null) {
            is.close();
         }
         if(os != null) {
            os.close();
         }
         if(c != null) {
            c.close();
         }
      }
      display.setCurrent(t);
   }     
}

(出處:http://www.companysz.com)



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 久久久久9999 | 欧美中文字幕在线视频 | 国产一级免费不卡 | 久久精品国产精品亚洲 | 毛片免费看的 | 免费播放av | 77成人影院 | 国产系列 视频二区 | 性插视频| 97色在线观看免费视频 | 热99在线视频 | 成人一区二区三区在线 | 一区二区三区在线播放视频 | 久久久久女人精品毛片九一 | xxxxxx免费| 午夜看毛片 | 91精品国产网站 | 精品久久久久久久久久久久久久 | 在线a毛片 | 中文字幕涩涩久久乱小说 | 男男羞羞视频网站国产 | 黄色片网站免费观看 | 国产伊人色 | 欧美成人影院 | 国产精品久久久久久久娇妻 | 亚洲视频精选 | 韩国草草影院 | 天天操很很操 | av在线看网站 | 在线观看91精品 | 欧美一级黄视频 | 一级黄色影院 | lutube成人福利在线观看污 | 一级黄色免费观看 | 91 免费视频 | 日本一区二区高清不卡 | 毛片av网 | 黑人日比| 中文字幕在线观看日韩 | 操操影视 | 欧美精品一区二区三区在线 |