socket普通类获取servlet返回信息问题
servlet类post方法代码如下:
PrintWriter pw = response.getWriter();
pw.print("OK");
pw.flush();
pw.close();
socket类接收servlet输出代码:
is = socket.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String s = br.readLine();
while(s != null){
System.out.println(s);
s = br.readLine();
}
具体输出情况
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=47D635BF539CD433B31D123C49EA69B0; Path=/Test
Content-Type: text/plain;charset=utf-8
Transfer-Encoding: chunked
Date: Tue, 13 Nov 2012 05:34:26 GMT
(空行)
2
OK
0
请问为什么在OK上下有个2和0,如果单纯获取OK字符串如何实现?
------解决方案--------------------你用socket和servlet通信?太奇葩了。自己写个服务器端吧。