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();
}