server为tomcat.
例如:server有一个List,browser有个table来显示这些List中的数据.
当像server端的List中添加数据时,就在broswer的table中添加这条新记录.(实时添加)
broswer与server有session.这可能实现吗?
例如:server有一个List,browser有个table来显示这些List中的数据.
当像server端的List中添加数据时,就在broswer的table中添加这条新记录.(实时添加)
broswer与server有session.这可能实现吗?
如果要再次获得数据那么就得再次请求,从新连接,再次请求.......所谓session可以把它看作是一个存放在服务端得口袋 你第一次操作可以把你操作得一些信息放进这个口袋 第二操作得时候你就会把这个口袋得编码传给服务器 服务器通过编码找到你的口袋 如果你需要你上一次得信息那么就取出 然后把你这一次得也存入这个口袋 在断开连接 以此类推所以说 你想让服务器来检测你的客户端 这个是不行得 协议不支持 不过你可以通过javaScript来辅助完成 因为javascript是作用于客户端得代码片断当然ftp协议是有状态得
我想问一下,socket服务端怎么知道有新数据来了呢?
socket客户端怎样与ie进行通信
http://community.csdn.net/Expert/topic/4327/4327158.xml?temp=.6255609
判断链接是否断开
http://community.csdn.net/Expert/topic/4210/4210348.xml?temp=.8907587
ajax是个不错的选择,但是它依然不能实现实时,因为它也是在CLIENT端设置时间来定时取回数据的因此使用SERVER PUSH技术也许是唯一的选择。查了一些文章,实现SERVER PUSH大约有两种方式:
1. 自己写一个server socket,让浏览器来连接这个SOCKET;但是它的弊端就是不能我HTTP SERVER 的端口
ajax是个不错的选择,但是它依然不能实现实时,因为它也是在CLIENT端设置时间来定时取回数据的
因此使用SERVER PUSH技术也许是唯一的选择。
查了一些文章,实现SERVER PUSH大约有两种方式:
1. 自己写一个server socket,让浏览器来连接这个SOCKET;但是它的弊端就是不能我HTTP SERVER 的端口相同。
2. 要设置response的某个值.(这中方式我喜欢),但是不知道怎么实现。郁闷。:(
<%@ page contentType="text/html; charset=GB2312" %>
<%@ page import="com.jstrd.sbgl.entity.*"%>
<%@ page import="com.jstrd.sbgl.common.*"%>
<%@ page import="java.text.*"%>
<%@ page import="java.util.*"%><% String queryStr = "select * from sb_yhxxb where 1=1 ";
Sb_Yhxxb_Ope sb_yhxxb_ope = new Sb_Yhxxb_Ope(); String k_name = request.getParameter("k_name");
if(k_name!=null && !k_name.trim().equals(""))
queryStr += " and k_name ='" + k_name.trim() + "'";
System.out.println(queryStr);
ArrayList list = sb_yhxxb_ope.query(queryStr);
if(session.getAttribute("list")!=null){
session.removeAttribute("list");
}
session.setAttribute("list",list);
if(session.getAttribute("queryStr")!=null){
session.removeAttribute("queryStr");
}
session.setAttribute("queryStr",queryStr);
response.sendRedirect("yhxx_query_result.jsp");
%>
<%@ page import="com.jstrd.sbgl.entity.*"%>
<%@ page import="java.util.*"%>
<%@ page import="com.jstrd.sbgl.common.*"%>
<html>
<head>
<title>用户信息</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="../allpageCSS.css">
</head><body bgcolor="#FFFFFF"><td bgcolor="#3366FF">
<table border="0" cellpadding="0" cellspacing="0" width="7">
<tr>
<td></td>
</tr>
</table>
</td>
<div align="center">
<form action="yhxx_del.jsp" method="post">
<%ArrayList list = (ArrayList)session.getAttribute("list");%>
<table width="100%" height="110" border="1" bordercolor="#B5C7A0">
<tr>
<td height="104" valign="top" bordercolor="#B5C7A0"><div align="center">
<table width="100%" border="0">
<tr>
<td bgcolor="#B5C7A0"><div align="center"><font color="#000000" size="-1">用户信息列表</font></div></td>
</tr>
</table>
</div>
<div align="center">
<table width="100%" border="1" align="center" cellpadding="0" cellspacing="1" bordercolor="#B5C7A0" >
<tr>
<td width="7%" nowrap CLASS=cSYS_GridHeadCell><div align="center"><font color="#000000" size="-1">选 择</font></div></td>
<td width="7%" nowrap CLASS=cSYS_GridHeadCell><div align="center"><font color="#000000" size="-1"> 用户编号 </font></div></td>
<td width="7%" nowrap CLASS=cSYS_GridHeadCell><div align="center"><font color="#000000" size="-1"> 用户名称 </font></div></td> <td width="6%" nowrap CLASS=cSYS_GridHeadCell><div align="center"><font color="#000000" size="-1">修改</font> </div></td>
</tr>
<%
if(list!=null && list.size() >0){
for(int i=0;i < list.size(); i++){
Sb_Yhxxb sb_yhxxb = (Sb_Yhxxb)list.get(i);
%>
<tr onmouseover=javascript:this.style.backgroundColor='#D0FAC0' onmouseout=javascript:this.style.backgroundColor='#ffffff'>
<td style='Border-style: Solid; Border-width: 1px;' nowrap><div align="center"><font color="#000000">
<input type="checkbox" name="checkbox" value="<%=sb_yhxxb.getK_id()%>">
</font></div></td>
<td style='Border-style: Solid; Border-width: 1px;' nowrap><div align="center"><font color="#000000"><%=i+1%></font></div></td>
<td style='Border-style: Solid; Border-width: 1px;' nowrap><div align="center"><font color="#000000"><%=Fiter.UnicodeToChinese(sb_yhxxb.getK_name())%> </font></div></td> <td style='Border-style: Solid; Border-width: 1px;' nowrap><div align="center"><font color="#000000"><a href="yhxx_modify_index.jsp?k_id=<%=sb_yhxxb.getK_id()%>"><font size="-1">修改</font></a></font></div></td>
</tr> <%}
}else{%>
<tr>
<td style='Border-style: Solid; Border-width: 1px;' colspan="5"><div align="center"><font color="#000000">#无记录</font></div></td>
</tr>
<%}%>
</table>
</div>
<table width="100%" border="0">
<tr>
<td bgcolor="#B5C7A0"><div align="left"><strong>
<input type="button" name="add" value="新增" onclick="window.location='yhxx_add_index.jsp'" class="button">
<input type="submit" name="delete" value="删除" class="button">
</strong></div></td>
</tr>
</table></td></tr>
</table>
</form>
<h1><br> </h1>
</div>
<p> </p>
</body>
</html>
现实一点的方法是ajax,刚写了一篇文章,推荐一下
http://blog.csdn.net/infowain/archive/2006/07/19/942384.aspx