反向Ajax + JSP-Servlet [英] Reverse Ajax + JSP-Servlet

查看:87
本文介绍了反向Ajax + JSP-Servlet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在尝试在我们的项目中创建反向Ajax.

我在网上检查过,没有发现具体的东西.我无法成功运行提供的任何教程.

我的对象是: 甚至在服务器甚至有推送请求时都可以提供屏幕警报(如弹出窗口)(这可能是CPU使用率高/内存高,等等).

解决方案

HTTP协议(毕竟,遗憾的是)不支持PUSH,因此它在那里停止.

最好的办法是让客户端按一定的时间间隔触发ajax轮询请求,我可以推荐 jQuery.ajax() setInterval()结合使用.

或者(稍加努力),您可以利用 Comet 技术(或多或少模拟虚拟HTTP PUSH).使用此关键字查看特定于Appserver的文档/Wiki,以获取详细信息.这是针对Tomcat的示例: http://wiki.apache.org/tomcat/WhatIsComet

,根据要求,这是Tomcat + Comet入门指南: 解决方案

The HTTP protocol (fortunately, after all) doesn't support PUSH, so it stops there.

Best what you can do is to let the client fire ajax poll requests at timed intervals I can recommend jQuery.ajax() in combination with setInterval() for this.

Alternatively (and with a bit more effort) you could make use of Comet technique (which simulates the fictive HTTP PUSH less or more). Check the appserver specific documentation/wiki using this keyword for details. Here's a Tomcat targeted example: http://wiki.apache.org/tomcat/WhatIsComet

Edit: as requested, here's a Tomcat+Comet tutorial to get started: http://www.ibm.com/developerworks/web/library/wa-cometjava/#N100CC Hope this helps.

这篇关于反向Ajax + JSP-Servlet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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