在聊天室里聊天内容不显示,为什么呢??
//dataValue.jsp<html><%@includefile="./checklogin.jsp"%><%@pagelanguage="java"import=...
//dataValue.jsp
<html>
<%@ include file="./checklogin.jsp" %>
<%@ page language="java" import="java.sql.*" pageEncoding="GB2312"%>
<%@ page import="com.util.DBConn"%>
<head>
<script language="javascript">
//javascript函数,每融2000毫秒(2秒)刷新一次页面
function GetData()
{
var timeoutid = setTimeout("window.location.reload()",2000)
}
</script>
</head>
<body onload="GetData()">
<%
String msgString = "";
Connection conn=null;
PreparedStatement stmt =null;
ResultSet rs =null;
String sql = "select * from msgInfo where ID in(select top 15 ID from msgInfo where chatRoom=? Order by chattime DESC) order by chattime";
String userName=(String)session.getAttribute("user_id");
String chatroom=(String)session.getAttribute("chatroom");
conn=DBConn.getConn();
stmt = conn.prepareStatement(sql);
stmt.setString(1,chatroom);
rs = stmt.executeQuery();
//下面while循环里的程序就是实现控制聊天信息显示格式的功能
while(rs.next())
{
String msgFrom = rs.getString("msgFrom");//获取聊天信息发送者
String msgTo=rs.getString("msgTo");//获取聊天信息接收者
String action = rs.getString("chatAction");//获取聊天表情
String msgContent=rs.getString("msgContent");//获取聊天信息内容
msgString=msgString+"<div><font color=blue>"+msgFrom+"</font>对<font color=blue>"+msgTo+"</font></span>说:"+msgContent+"</div>";
%>
<script language="javascript">
//注意这里的javascript,在show.jsp中定义了一个id为loadContent的span
//这里就是在id为loadContent的地方显示msgString,也就是显示聊天信息
parent.loadContent.innerHTML="<%=msgString%>";
parent.location.hash="position";
</script>
</body>
</html>
//show.jsp
<html>
<%@ page language="java" pageEncoding="utf-8"%>
<head>
<script language="javascript" type="text/javascript">
function GetPosition()
{
window.location.hash="position";
}
function GetData()
{
url="dataValue.jsp";//调用页面
var http = new ActiveXObject("Microsoft.XMLHTTP");
http.open("GET",url,false);
http.send();
var str = http.responseText;
loadContent.innerHTML=str;
setTimeout("GetData()",1000);
}
</script>
</head>
<body onload="GetData()" background="images\4.jpg">
<span id="loadContent">data is loading</span>
<a id="position"></a>
</body>
</html> 展开
<html>
<%@ include file="./checklogin.jsp" %>
<%@ page language="java" import="java.sql.*" pageEncoding="GB2312"%>
<%@ page import="com.util.DBConn"%>
<head>
<script language="javascript">
//javascript函数,每融2000毫秒(2秒)刷新一次页面
function GetData()
{
var timeoutid = setTimeout("window.location.reload()",2000)
}
</script>
</head>
<body onload="GetData()">
<%
String msgString = "";
Connection conn=null;
PreparedStatement stmt =null;
ResultSet rs =null;
String sql = "select * from msgInfo where ID in(select top 15 ID from msgInfo where chatRoom=? Order by chattime DESC) order by chattime";
String userName=(String)session.getAttribute("user_id");
String chatroom=(String)session.getAttribute("chatroom");
conn=DBConn.getConn();
stmt = conn.prepareStatement(sql);
stmt.setString(1,chatroom);
rs = stmt.executeQuery();
//下面while循环里的程序就是实现控制聊天信息显示格式的功能
while(rs.next())
{
String msgFrom = rs.getString("msgFrom");//获取聊天信息发送者
String msgTo=rs.getString("msgTo");//获取聊天信息接收者
String action = rs.getString("chatAction");//获取聊天表情
String msgContent=rs.getString("msgContent");//获取聊天信息内容
msgString=msgString+"<div><font color=blue>"+msgFrom+"</font>对<font color=blue>"+msgTo+"</font></span>说:"+msgContent+"</div>";
%>
<script language="javascript">
//注意这里的javascript,在show.jsp中定义了一个id为loadContent的span
//这里就是在id为loadContent的地方显示msgString,也就是显示聊天信息
parent.loadContent.innerHTML="<%=msgString%>";
parent.location.hash="position";
</script>
</body>
</html>
//show.jsp
<html>
<%@ page language="java" pageEncoding="utf-8"%>
<head>
<script language="javascript" type="text/javascript">
function GetPosition()
{
window.location.hash="position";
}
function GetData()
{
url="dataValue.jsp";//调用页面
var http = new ActiveXObject("Microsoft.XMLHTTP");
http.open("GET",url,false);
http.send();
var str = http.responseText;
loadContent.innerHTML=str;
setTimeout("GetData()",1000);
}
</script>
</head>
<body onload="GetData()" background="images\4.jpg">
<span id="loadContent">data is loading</span>
<a id="position"></a>
</body>
</html> 展开
1个回答
展开全部
//dataValue.jsp
<html>
<%@ include file="./checklogin.jsp" %>
<%@ page language="java" import="java.sql.*" pageEncoding="GB2312"%>
<%@ page import="com.util.DBConn"%>
<head>
<script language="javascript">
//javascript函数,每融2000毫秒(2秒)刷新一次页面
function GetData()
{
var timeoutid = setTimeout("window.location.reload()",2000)
}
</script>
</head>
<body onload="GetData()">
<%
String msgString = "";
Connection conn=null;
PreparedStatement stmt =null;
ResultSet rs =null;
String sql = "select * from msgInfo where ID in(select top 15 ID from msgInfo where chatRoom=? Order by chattime DESC) order by chattime";
String userName=(String)session.getAttribute("user_id");
String chatroom=(String)session.getAttribute("chatroom");
conn=DBConn.getConn();
stmt = conn.prepareStatement(sql);
stmt.setString(1,chatroom);
rs = stmt.executeQuery();
//下面while循环里的程序就是实现控制聊天信息显示格式的功能
while(rs.next())
{
String msgFrom = rs.getString("msgFrom");//获取聊天信息发送者
String msgTo=rs.getString("msgTo");//获取聊天信息接收者
String action = rs.getString("chatAction");//获取聊天表情
String msgContent=rs.getString("msgContent");//获取聊天信息内容
msgString=msgString+"<div><font color=blue>"+msgFrom+"</font>对<font color=blue>"+msgTo+"</font></span>说:"+msgContent+"</div>";
%>
<script language="javascript">
//注意这里的javascript,在show.jsp中定义了一个id为loadContent的span
//这里就是在id为loadContent的地方显示msgString,也就是显示聊天信息
parent.loadContent.innerHTML="<%=msgString%>";
parent.location.hash="position";
</script>
</body>
</html>
//show.jsp
<html>
<%@ page language="java" pageEncoding="utf-8"%>
<head>
<script language="javascript" type="text/javascript">
function GetPosition()
{
window.location.hash="position";
}
function GetData()
{
url="dataValue.jsp";//调用页面
var http = new ActiveXObject("Microsoft.XMLHTTP");
http.open("GET",url,false);
http.send();
var str = http.responseText;
loadContent.innerHTML=str;
setTimeout("GetData()",1000);
}
</script>
</head>
<body onload="GetData()" background="images\4.jpg">
<span id="loadContent">data is loading</span>
<a id="position"></a>
</body>
</html>
<html>
<%@ include file="./checklogin.jsp" %>
<%@ page language="java" import="java.sql.*" pageEncoding="GB2312"%>
<%@ page import="com.util.DBConn"%>
<head>
<script language="javascript">
//javascript函数,每融2000毫秒(2秒)刷新一次页面
function GetData()
{
var timeoutid = setTimeout("window.location.reload()",2000)
}
</script>
</head>
<body onload="GetData()">
<%
String msgString = "";
Connection conn=null;
PreparedStatement stmt =null;
ResultSet rs =null;
String sql = "select * from msgInfo where ID in(select top 15 ID from msgInfo where chatRoom=? Order by chattime DESC) order by chattime";
String userName=(String)session.getAttribute("user_id");
String chatroom=(String)session.getAttribute("chatroom");
conn=DBConn.getConn();
stmt = conn.prepareStatement(sql);
stmt.setString(1,chatroom);
rs = stmt.executeQuery();
//下面while循环里的程序就是实现控制聊天信息显示格式的功能
while(rs.next())
{
String msgFrom = rs.getString("msgFrom");//获取聊天信息发送者
String msgTo=rs.getString("msgTo");//获取聊天信息接收者
String action = rs.getString("chatAction");//获取聊天表情
String msgContent=rs.getString("msgContent");//获取聊天信息内容
msgString=msgString+"<div><font color=blue>"+msgFrom+"</font>对<font color=blue>"+msgTo+"</font></span>说:"+msgContent+"</div>";
%>
<script language="javascript">
//注意这里的javascript,在show.jsp中定义了一个id为loadContent的span
//这里就是在id为loadContent的地方显示msgString,也就是显示聊天信息
parent.loadContent.innerHTML="<%=msgString%>";
parent.location.hash="position";
</script>
</body>
</html>
//show.jsp
<html>
<%@ page language="java" pageEncoding="utf-8"%>
<head>
<script language="javascript" type="text/javascript">
function GetPosition()
{
window.location.hash="position";
}
function GetData()
{
url="dataValue.jsp";//调用页面
var http = new ActiveXObject("Microsoft.XMLHTTP");
http.open("GET",url,false);
http.send();
var str = http.responseText;
loadContent.innerHTML=str;
setTimeout("GetData()",1000);
}
</script>
</head>
<body onload="GetData()" background="images\4.jpg">
<span id="loadContent">data is loading</span>
<a id="position"></a>
</body>
</html>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询