Topic: ~关于模拟post method传送数据至asp page的问题

  Print this page

1.~关于模拟post method传送数据至asp page的问题 Copy to clipboard
Posted by: alexlex
Posted on: 2004-10-12 15:57

asp page url见代码
使用ie打开,输入错误信息会出现下列出错信息

*** This MemberID cannot be found ***

如果在url里直接加参数传过去,返回页面是无错误信息的

用如下代码,得到的html里面却不含出错信息,怀疑是否没能正确模拟
但是使用本机的tomcat作试验,这个方法可以post数据到jsp/servlet

老板交给我的任务,大家表鄙视我~.~


try {
      
      String urlstr = "http://www.gamenz.com/Membership/Member_Log_in.asp";
      String query = "MemberID=test&Password=test";

      URL url = new URL(urlstr);
      URLConnection uc = url.openConnection();

      uc.setDoOutput(true);
      PrintStream out = new PrintStream(uc.getOutputStream());
      out.println(query);
      out.close();

      DataInputStream in = new DataInputStream(uc.getInputStream());
      String line;
      while ((line = in.readLine()) != null) {
        System.out.println(line);
      }
    } catch (MalformedURLException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }

2.Re:~关于模拟post method传送数据至asp page的问题 [Re: alexlex] Copy to clipboard
Posted by: floater
Posted on: 2004-10-12 22:08

Must be some html post parameters are not matched on the server side,
e.g., try these
setUseCaches(false);
setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

There are others, check html doc for others.


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923