我尝试写一个客户端服务器程序,在我的程序,每一轮,客户端发送两个String
到服务器,第一个是网络地址和第二个约user.but一些随机的信息时,URL地址到达服务器,我得到这个异常:HTTP响应代码:403客户端发送一个URL地址时,服务器
Exception in thread "main" java.io.IOException: Server returned HTTP response code: 403 for URL: http://www.google.com.hk/search?hl=en&source=hp&q=java&gbv=2
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1245)
at java.net.URL.openStream(URL.java:1009)
at server.Server.processClient(Dom.java:124)
at server.Server.run(Dom.java:90)
at server.Server.main(Dom.java:155)
Java Result: 1
,但我不知道为什么得到一个禁止访问响应。
客户端
private static BufferedWriter toServer;
....
public void progressUpdated(NavigatorProgressEvent npe) {
Matcher matcher = pattern.matcher (npe.getUrl().toString());
if (matcher.matches())
{
System.out.println(npe.getUrl());
toServer.println(npe.getUrl().toString());
}
服务器端
...
url = new URL(fromClient.readLine());
....
请把你的源代码了。 – dash1e 2012-04-07 05:04:27
@ dash1e查看更新 – lonesome 2012-04-07 05:08:30