网页中实时显示数据库数据的问题?(应用了xmlhttp)
我应用xmlhttp写了一个实时显示数据的程序,由于初次使用,查了很多资料仍然不得要领,下面是我的代码,请大家看看,该怎么改,(数据库应用了hibernate)
dataread.jsp文件代码:
<%@page contentType= "text/html;charset=GB2312 "%>
<%@page language= "java "%>
<%@page import= "java.util.* "%>
<%@page import= "java.sql.* "%>
<%@page import= "org.hibernate.Session "%>
<%@page import= "org.hibernate.SessionFactory "%>
<%@page import= "org.hibernate.cfg.Configuration "%>
<%@page import= "org.hibernate.Query "%>
<%@page import= "com.tianhe.dao.hbm.DCqttestdata "%>
<%@page import= "com.tianhe.dao.hbm.DCqttestdataId "%>
<%@page import= "com.tianhe.dao.hbm.DCqttestdataHome "%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd ">
<html>
<head>
<title>
</title>
</head>
<body bgcolor= "#ffffff ">
<script type= "text/javascript ">
<%
Configuration conf=new Configuration().configure();
SessionFactory sessionFactory = conf.buildSessionFactory();
Session s = sessionFactory.openSession();
DCqttestdata dcd =new DCqttestdata();
Query qr=s.createQuery( "from DCqttestdata as dcqt order by dcqt.id.revTime desc ");
String sResult;
if (qr.list().size()> 0)
{
dcd=(DCqttestdata)qr.list().get(0);
}
sResult=dcd.getBsic() + "@@ " + dcd.getCellid() + "@@ " + dcd.getCh();
out.print(sResult);
//System.out.println(sResult);
%>
</script>
</body>
</html>
datadisplay.jsp代码
<%@page contentType= "text/html;charset=GB2312 "%>
<%@page language= "java "%>
<%@page import= "java.util.* "%>
<%@page import= "java.sql.* "%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd ">
<html>
<head>
<title>
datadisplay
</title>
<script type= "text/javascript ">
function GetResult()
{
try
{
//var oBao = new ActiveXObject( "Msxml2.XMLHTTP ");
var oBao = new ActiveXObject( "Microsoft.XMLHTTP ");
oBao.open( "GET ", "dataread.jsp ",false);
&nbs