<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    konhon

    忘掉過去,展望未來。找回自我,超越自我。
    逃避不一定躲的過, 面對(duì)不一定最難過, 孤單不一定不快樂, 得到不一定能長久, 失去不一定不再擁有, 可能因?yàn)槟硞€(gè)理由而傷心難過, 但我卻能找個(gè)理由讓自己快樂.

    Google

    BlogJava 首頁 新隨筆 聯(lián)系 聚合 管理
      203 Posts :: 0 Stories :: 61 Comments :: 0 Trackbacks

    服務(wù)器:
    1.jsp
    <body>
    <form name="_ctl0" method="post" action="TestFileManager.aspx" id="_ctl0" enctype="multipart/form-data">
    <input type="hidden" name="__VIEWSTATE" value="dDwyNTIzNjA5NDU7Oz7rsE3eBYzQHDVtl+aTn96MvQW6PQ==" />
    <p>
    <input name="uploadfile1" id="uploadfile1" type="file" size="49" />
    <input type="submit" name="Button1" value="?" id="Button1" />
    </p>
    <p>
    <span id="Label1" style="width:459px;"></span>
    </p>
    <!-- Insert content here -->
    </form>
    </body>
    客戶端:
    首先創(chuàng)建一個(gè)到服務(wù)器http的請(qǐng)求
    HttpRequest request = new HttpRequest("http://服務(wù)器/1.jsp");
    第一次使用的是GET方式
    request.setMethod("GET");
    緊接著進(jìn)行一些請(qǐng)求的屬性設(shè)置
    request.setRequestHeader("Cache-Control", "no-cache");
    這里保持連接,因?yàn)楹竺孢€要發(fā)送數(shù)據(jù)到服務(wù)器呢
    request.setRequestHeader("Connection", "Keep-Alive");
    下面是一些無關(guān)緊要的屬性設(shè)置了。
    request.setRequestHeader("Accept", "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*");
    request.setRequestHeader("Accept-Encoding", "gzip, deflate");
    request.setRequestHeader("Accept-Language", "en-au");
    request.setRequestHeader("Referer", "http://服務(wù)器/1.jsp");
    request.setRequestHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3215; .NET CLR 1.0.3705)");
    構(gòu)造好了連接請(qǐng)求,然后連接
    request.connect();
    緊接著提取Cookie值,在后文的post中可以用到。
    String strCookie = request.getResponseHeader("Set-Cookie");
    strCookie = strCookie.substring(0,strCookie.indexOf(";"));
    下面通過循環(huán)查找,提取__VIEWSTATE的值
    for ( int i = 0; i < nlist.getLength(); i++) {
    node = nlist.item(i);
    strName = getNodeAttributeValue(node,"name");
    if ( strName.equals("__VIEWSTATE") ) {
    strValue = getNodeAttributeValue(node,"value");
    break;
    }
    }
    往服務(wù)器組織發(fā)送數(shù)據(jù)
    DataOutputStream dos = new DataOutputStream(request.getOutputStream());
    dos.writeBytes("-----------------------------"+strBoundary);//這是每個(gè)要被發(fā)送數(shù)據(jù)間的間隔
    dos.writeBytes(" Content-Disposition: form-data; name="__VIEWSTATE"");
    dos.writeBytes(" "+strValue);
    dos.writeBytes(" -----------------------------"+strBoundary);
    這里面是發(fā)送文件的部分
    dos.writeBytes(" Content-Disposition: form-data; name="uploadfile1"; filename="" + strFileName + """);
    dos.writeBytes(" Content-Type: text/xml");
    dos.writeBytes(" ");
    dos.writeBytes(new String(data));
    dos.writeBytes(" -----------------------------"+strBoundary);
    dos.writeBytes(" Content-Disposition: form-data; name="Button1"");
    dos.writeBytes(" 上傳");
    dos.writeBytes(" -----------------------------"+strBoundary+"--");
    dos.writeBytes(" ");
    dos.close();
    posted on 2007-03-07 20:14 konhon 優(yōu)華 閱讀(4266) 評(píng)論(1)  編輯  收藏

    Feedback

    # re: 用JAVA模擬POST發(fā)送數(shù)據(jù) [未登錄] 2009-05-12 03:42 ck
    HttpRequest是什么東西呢?  回復(fù)  更多評(píng)論
      


    只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 国产va在线观看免费| 曰韩无码AV片免费播放不卡 | 亚洲经典千人经典日产| 亚洲视频免费在线看| 亚洲精品自产拍在线观看动漫| 一区在线免费观看| 日韩亚洲变态另类中文| 亚洲免费一区二区| 亚洲国产精品自产在线播放| 免费看黄福利app导航看一下黄色录像| 国产在线观看www鲁啊鲁免费| 亚洲AⅤ男人的天堂在线观看| 四虎影院永久免费观看| 全黄A免费一级毛片| 国产亚洲精品成人AA片新蒲金| 午夜在线免费视频 | 日本视频免费在线| 国产精品亚洲色图| 久久乐国产精品亚洲综合| 精选影视免费在线 | 久久久亚洲欧洲日产国码农村| 久久久久久夜精品精品免费啦| 亚洲精品人成电影网| 免费无码A片一区二三区| 亚洲av成人无码网站…| 亚洲另类少妇17p| 国色精品va在线观看免费视频| 亚洲国产成人久久综合碰碰动漫3d| 97青青草原国产免费观看| 亚洲中文字幕一二三四区| 亚洲国产专区一区| 久久久免费精品re6| 亚洲av无码一区二区三区人妖 | 精品久久久久久国产免费了| 亚洲福利视频一区| 日本无吗免费一二区| 91视频免费网站| 中文字幕亚洲男人的天堂网络| 亚洲日韩在线观看免费视频| 中文字幕天天躁日日躁狠狠躁免费| 亚洲另类自拍丝袜第五页|