out.println后要out.flush()的!
要么就
out = new PrintWriter(socket.getOutputStream(),true);
要么就
out = new PrintWriter(socket.getOutputStream(),true);
解决方案 »
- hibernte 保存 Clob数据 出异常。。
- glassfish连接数据源错误
- 32位和64位JVM,有人遇到过吗
- 看技术书的时候你们有没有这种感觉。
- Hibernate的配置文件hibernate.cfg.xml为什么找不到(送分的问题哦)
- Resin比Tomcat好的地方
- james如何配置才能发邮件到外网啊?
- 在Eclipse里怎样使用Junit测试已经部署到weblogic上的EJB(EJB是在JB9中开发的)
- 各位高人,帮帮忙!急死我了。
- 请教:在jbuilder7下怎样开发EJB程序,为什么创建ejb的选项总是是灰色的
- 关于java的小程序applet的一个问题?
- jboss&jsp求救!
out = new PrintWriter(socket.getOutputStream(),true);
还是不行!
有没这方面的源码啊?
POST /xxx.jsp HTTP/1.1
Host: www.mywebsit.com
Content-Length: <Content-Length>
<param1>=<paramValue>
这个格式是项目文档上的例子!我想应该是正确的把!
POST http://news.sina.com.cn/c/2004-12-21/10084584671s.shtml HTTP/1.0
User-Agent: myselfHttp/1.0
Accept: www/source; text/html; image/gif; */*
Host: news.sina.com.cn
Content-type: application/x-www-form-urlencoded
Content-length: 30alumniuname=kkk&alumniupwd=kkksource:
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.Socket;
import java.net.URL;/*
* Created on 2004-12-21
*
* To change the template for this generated file go to Window - Preferences -
* Java - Code Generation - Code and Comments
*//**
* @author Artimus
*
* To change the template for this generated type comment go to Window -
* Preferences - Java - Code Generation - Code and Comments
*/
public class ConnectUrl { private static final String OPEN_URL = "http://news.sina.com.cn/c/2004-12-21/10084584671s.shtml"; public static void main(String[] args) {
Socket client = null;
BufferedOutputStream sender = null; try {
URL webURL = new URL(OPEN_URL);
InetAddress address = InetAddress.getByName(webURL.getHost());
int portTemp = webURL.getPort();
if (portTemp == -1) {
portTemp = 80;
}
client = new Socket(address, portTemp);
String content = "alumniuname=kkk&";
content += "alumniupwd=kkk"; String cmd = "POST " + OPEN_URL + " HTTP/1.0\r\n" + getBaseHeads();
cmd += "Host: " + webURL.getHost() + "\r\n";
cmd += "Content-type: application/x-www-form-urlencoded\r\n";
cmd += "Content-length: " + content.length() + "\r\n\r\n";
cmd += content + "\r\n";
System.out.println(cmd);
// sender = new BufferedOutputStream(client.getOutputStream());
sender.write(cmd.getBytes(), 0, cmd.length());
sender.flush(); BufferedReader out = new BufferedReader(new InputStreamReader(
client.getInputStream()));
int b;
String line = null;
int i = 0;
if (out != null) {
while ((line = out.readLine()) != null) {
System.out.println(line);
}
out.close();
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (client != null) {
client.close();
client = null;
}
} catch (Exception e) {
// TODO: handle exception
}
}
}
/** **************************** */
public static String getBaseHeads() {
String inf = "User-Agent: myselfHttp/1.0\r\n"
+ "Accept: www/source; text/html; image/gif; */*\r\n";
return inf;
}}
// sender = new BufferedOutputStream(client.getOutputStream());