日期:2014-05-18  浏览次数:20684 次

大家来帮我看看。jsp的聊天室。能看到自己说的话,不能看到别人说的话是什么原因。有代码。。
框架页面 frame.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>在线交流</title>
</head>
<frameset rows="*,80,60" frameborder="NO" border="1" framespacing="2">
<frameset cols="*,200" frameborder="NO" border="1" framespacing="2">
<frameset rows="*,*" frameborder="NO" border="1" framespacing="2">
<frame src="1.jsp" name="gonggao" scrolling="yes" >

<frame src="2.html" name="myspeak" >
</frameset>
<frame src="33.jsp" name="namelist" scrolling="yes" noresize>
</frameset>
<frame src="4.html" name="sendtalk" scrolling="NO" noresize>
<frame src="5.html" name="bottomFrame" scrolling="NO" noresize>
</frameset>
<noframes><body>
</body></noframes>
</html>

信息提交页4.html
<html> 
  <head> 
  <title>聊天内容录入区</title> 
  <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> 
  </head> 
   
  <body bgcolor="#FFFFFF"> 
  <form name="form1" method="POST" action="1.jsp" target="gonggao"> 
  <div align="center"> 
  <input type="text" name="message"> 
  <input type="submit" name="Submit" value="写写看"> 
  </div> 
  </form> 
  </body> 
  </html>

信息接收页1.jsp
<%@ page language="java" contentType="text/html;charset=gb2312" import="java.util.*"%>
<%
String talkmessage = request.getParameter("message");//获得前台说的话
if(talkmessage == null) talkmessage = "";
session.setAttribute("speak",talkmessage);//把说的话放入到SESSION中
//System.out.println((String)session.getAttribute("speak"));
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html> 
<head> 
<title>聊天内容显示区</title> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"> 
<script language="javascript" src="function/ajax2.js"></script>
<script language="javascript">
function windowLoad()
{//页面加载,获取全部内容
send_request("get","/jtjtalkabout/SelectTalkMessage?time="+ new Date().getTime(),null,"XML",populateLists);
setTimeout("windowLoad()", 10000);
}
//将所获取的新闻列表填充到页面的相应位置
function populateLists() {
if (http_request.readyState == 4) { // 判断对象状态
if (http_request.status == 200) { // 信息已经成功返回,开始处理信息
var doc="";
var doc = http_request.responseXML;
var newslist = "";
var innerHTML = "";

var talklist = doc.getElementsByTagName("talkmessage");//获得说话列表的标签

///////显示人数
if(talklist == null || talklist.lengt