请高手们解决下面的问题
public class CookieManager {
public CookieManager() {
}
public static void main(String[] argv) throws Exception {
URL url = new URL("http://61.188.176.149/idc3/check1.php");
//URL url = new URL("http://mail1.optisp.com:8080/TestPost.jsp");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
InputStream is = connection.getInputStream();
BufferedReader in
= new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
System.out.println(line);
}
in.close();
}
}
为什么我这么联过去它老是抱如下错误:
com.optisp.common.net.CookieManager
java.net.MalformedURLException: no protocol: error.php
at java.net.URL.<init>(URL.java:579)
at java.net.URL.<init>(URL.java:476)
at java.net.URL.<init>(URL.java:425)
at sun.net.www.protocol.http.HttpURLConnection.followRedirect(HttpURLConnection.java:1081)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:675)
at com.optisp.common.net.CookieManager.main(CookieManager.java:22)
Exception in thread "main"
问题点数:0、回复次数:6Top
1 楼killme2008(为了生态平衡,请保护蛤蟆)回复于 2003-12-03 12:53:16 得分 0
协议异常,.php不行
我也不知道为什么,你换个url试试
关注。。。。
Top
2 楼ruanshaobo(郁闷的人)回复于 2003-12-03 13:31:13 得分 0
URL url = new URL("http://61.188.176.149/idc3/step1.php");
可以的我想跟.php是无关的.
但是如果check1.php的话我估计这个问题是做了些判断然后跳到error.php或step2.php,
真搞不懂是为什么?Top
3 楼killme2008(为了生态平衡,请保护蛤蟆)回复于 2003-12-03 14:10:35 得分 0
你是不是php和java混用??
up一下
好久没搞php了啊Top
4 楼Shrewdcat(丧邦&灵猫&潇)回复于 2003-12-03 15:03:49 得分 0
添加:
import java.net.*;
import java.io.*;
然后:
try{
URL url = new URL("http://www.sohu.com");
//URL url = new URL("http://mail1.optisp.com:8080/TestPost.jsp");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
InputStream is = connection.getInputStream();
BufferedReader in = new BufferedReader(new InputStreamReader(connection.
getInputStream()));
String line;
while ( (line = in.readLine()) != null) {
System.out.println(line);
}
in.close();
}
catch(Exception e){
}
URL抛出的异常未加处理,所以有你的那些错误出现。
Top
5 楼Shrewdcat(丧邦&灵猫&潇)回复于 2003-12-03 15:07:22 得分 0
URL url = new URL("http://61.188.176.149/idc3/step1.php");
这是结果:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>互联星空2003中国游戏产业调查</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<LINK href="images/all.css" type=text/css rel=stylesheet>
<META content="MSHTML 6.00.2800.1264" name=GENERATOR></HEAD>
<BODY text=#333333 vLink=#000000 aLink=#000000 link=#000000 bgColor=#ffffff
leftMargin=0 background=images/bg_side.gif topMargin=0 marginheight="0"
marginwidth="0">
<div align="center">
<iframe name="head" src="http://user.chinavnet.com/ui/header.aspx" height="118" width="800" scrolling="no" noResize border=0 frameBorder=0 marginheight="0" marginwidth="0"></iframe>
</div>
<TABLE cellSpacing=0 cellPadding=0 width=800 align=center background=""
border=0>
<TBODY>
<TR>
<TD vAlign=top width=703 bgColor=#ffffff>
<TABLE cellSpacing=0 cellPadding=0 width=800 border=0>
<TBODY>
<TR>
<TD height=46 align=middle><img src="images/title.gif" width="800" height="65"></TD>
</TR>
</TBODY>
</TABLE>
<TABLE cellSpacing=0 cellPadding=0 width=800 border=0>
<TBODY>
<TR>
<TD colSpan=2><IMG height=1 src="images/spacer.gif"
width=1></TD></TR>
<TR>
<TD width=702 bgColor=#FF6600 height=16>
<TABLE cellSpacing=1 cellPadding=1 width="95%" border=0>
<TBODY>
<TR>
<TD><FONT color=#CCCCCC>| <a href="http://gnnic.chinavnet.com"><font color="#FFFFFF">活动说明</font></a>
| <a href="jp.htm"><font color="#FFFFFF">奖品设置</font></a>
| <a href="dc.htm"><font color="#FFFFFF">调查问卷</font></a>
| </FONT><a href="game.htm"><font color="#FFFFFF">游戏充值</font></a><FONT color=#CCCCCC>
| <a href="joy.htm"><font color="#FFFFFF">China Joy</font></a><font color="#FFFFFF">
Top
6 楼Shrewdcat(丧邦&灵猫&潇)回复于 2003-12-03 15:08:21 得分 0
20该全部给我拉。Top




