java tomcat6 - 如何在添加数据时自动刷新页面? [英] java tomcat6 - How to automatically refresh page when a data is added?

查看:119
本文介绍了java tomcat6 - 如何在添加数据时自动刷新页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先让我解释一下我正在做什么。我试图创建一个非常简单的基于Web的聊天程序。在我的开发中,我有2个只使用1个IP地址。正在使用的IP地址是运行tomcat6服务器的IP地址。简单的聊天连接到数据库。如果我的问题可能听起来很愚蠢,请原谅我,我会如何让网页自动更新,当其他电脑在数据库中输入数据(消息)时,无需重新加载页面。

。我没有聊天程序的经验。请帮助。

解决方案

您可以尝试webSockets。它是html5中的一项新功能。它允许你做全双工通信。它非常简单。你将不得不做客户端和服务器端。为了做服务器端,你需要tomcat 7.0.32。它包含一个新的WebSocketServlet。
这些链接可能会帮助你。

http://tomcat.apache.org/tomcat-7.0-doc/web-socket-howto.html



http://svn.apache.org/viewvc/tomcat / trunk / webapps / examples / websocket /

http://svn.apache.org/viewvc/tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/

first of all let me explain what Im tring to do. Im trying to create a very simple web based chat program. In my development I have 2 pcs using only 1 ip address. The ip address that is being used is the ip address which runs the tomcat6 server. The simple chat is connected to the database. How will I make the web page automatically update when the other pc input data(message) in the database without reloading the page.

Please forgive me if my question might sound idiotic. I have no experience in chat program. Please help.

解决方案

You can try webSockets. Its a new feature in html5. It allows you to do full duplex communication. Its very simple. You will have to do both client side and server side. For doing the server side you will need tomcat 7.0.32. It contains a new WebSocketServlet. These links may help you..

http://tomcat.apache.org/tomcat-7.0-doc/web-socket-howto.html

http://svn.apache.org/viewvc/tomcat/trunk/webapps/examples/websocket/

http://svn.apache.org/viewvc/tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/

这篇关于java tomcat6 - 如何在添加数据时自动刷新页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆