简体   繁体   English

基于Web的应用程序中的更新方法-Java Servlets

[英]Updating Method in Web-Based application - Java Servlets

I'm writing a servlet based back-end for a mobile phone app and I'm pretty new to web programming in general. 我正在为手机应用程序编写一个基于servlet的后端,并且对于Web编程而言,我还是很新的。

Anyways my issue is I have a data model that associates users to a general feed and when that feed is updated by any one user I want the rest of the users associated with the feed to receive the updated model. 无论如何,我的问题是我有一个将用户与常规供稿关联的数据模型,并且当任何一个用户更新该供稿时,我都希望与该供稿关联的其余用户接收更新的模型。

From what I gather at the moment a servlet can only send a response when it receives a request which isn't exactly what I'm looking for as the users would need to ping the servlet for changes every once few seconds which doesn't seem very practical. 从目前的情况来看,servlet只能在收到请求时发送响应,而这恰恰不是我在寻找的请求,因为用户需要每隔几秒钟对servlet进行一次ping操作,这似乎并没有很实用。 Instead I want the server to send out the response to the users on its own when it detects changes in the model. 相反,我希望服务器在检测到模型中的更改时自行将响应发送给用户。

I'm sure there's a clean and well documented solution for this I just can't put a name to it. 我敢肯定有一个干净且有据可查的解决方案,我只是不能为它起个名字。 From what I gather I basically need to generate HttpResponses without explicit requests (I was thinking HttpSession objects would have a way of doing this but it doesn't seem like it). 从我收集到的信息来看,我基本上需要在没有显式请求的情况下生成HttpResponses(我当时以为HttpSession对象可以做到这一点,但看起来并不像这样)。

It seems using a Comet implementation is the best way to handle this type of server pushing. 看来使用Comet实现是处理此类服务器推送的最佳方法。 Thanks for pointing me in the right direction. 感谢您指出正确的方向。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM