客户端代码:HttpURLConnection httpConn = (HttpURLConnection) httpurl
.openConnection();
httpConn.setDoOutput(true);
httpConn.setDoInput(true);httpConn.setRequestProperty("Connection", "keep-alive");
PrintWriter out = new PrintWriter(httpConn.getOutputStream());
out.print("**39000000101356433677500");
out.flush();InputStream in = httpConn.getInputStream();
/**********************************
这里服务器端doPost方法响应,读出了*39000000101356433677500
***********************************/Runnable myThreadUse=new testTrackeListen(new DataInputStream(in));
        Thread myThread=new Thread(myThreadUse);
        myThread.start();/**********************************
服务器端读了一次**39000000101356433677500 ,下面的**39全部收不到
***********************************/
while (true)
{out.print("**39000000101356433677500");
out.flush();
}
服务器端  public void event(CometEvent event) throws IOException, ServletException {
// protocol="org.apache.coyote.http11.Http11NioProtocol"HttpServletRequest request = event.getHttpServletRequest();
HttpServletResponse response = event.getHttpServletResponse();
                        if (event.getEventType() == CometEvent.EventType.READ) {
PrintWriter out = response.getWriter();
InputStream is = request.getInputStream();
System.out.println("开始");
int a = 0;
while (true) {
byte[] buf = new byte[512];
do {
System.out.println("正在读");
int n = is.read(buf);
System.out.println("读完a  "+n);
/**********************************
只读了一次**39000000101356433677500 ,InputStream in = httpConn.getInputStream();之前发送的那次,下面的**39全部收不到,bytesread全部是-1;
***********************************/} while (is.available() > 0);try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}String msg = "a" + a;
try {
out.write(msg);
out.flush();
} catch (Exception e) {
e.printStackTrace();
}
a++;
}
}今天用了tomcat6的comet ,代码如上,
int n = is.read(buf);这句就读出了一次“**39”
客户端InputStream in = httpConn.getInputStream();之前发送的那次,接下来读出的全是-1,
和普通servlet一模一样,哪位高手近来看一看 我从普通servlet 调到tomcat6的comet,调出的结果一模一样 , servlet中的  InputStream is = request.getInputStream();只能读一次请求 ,不能持续不断的读客户端发送的内容。是不是真是这样。如果真是这样comet吹的神乎其神也不过如此,还说什么下一代ajax,有n中方式从服务器主动向客户段退数据,我太孤落寡闻了,那位高手能解答一下,另外手机端要用cmwap,所以不能用socket,不用推荐用socket了。