简体   繁体   中英

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.

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. 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).

It seems using a Comet implementation is the best way to handle this type of server pushing. Thanks for pointing me in the right direction.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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