如何为 Web 应用程序推送通知(java/servlet)? [英] how push notification (java/ servlet) for web application?

查看:37
本文介绍了如何为 Web 应用程序推送通知(java/servlet)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我必须显示有关发生的特定操作的通知?

In my application I have to show a notification on a particular action taken place ?

然后我必须向登录用户显示通知..

I have to show logged in user a notification then. .

1-获得通知的一种方法是在特定时间间隔后继续轮询.那是拉取通知.

1-One way to get notification is to keep polling after certain time interval . that is pull notification.

但这会对服务器造成不必要的点击.

but this causes unnecessary hits to server.

如何在操作时使用来自服务器的推送通知..?(我在 tomcat 中使用 java(servlet/jsp))

how Can I use push notification from server upon action. .? (I am using java(servlet/jsp) with tomcat)

推荐答案

如今,一种很有前景的客户端-服务器通信方式是使用 Websocket.

Nowadays a promising way of client-server communication is to use Websockets.

参见什么是长轮询,Websockets、Server-Sent Events (SSE) 和 Comet 与 Websockets 一起查看其他一些方式,以及 Websockets 的优点和介绍,请参见 WebSocket 简介

See What are Long-Polling, Websockets, Server-Sent Events (SSE) and Comet to see some other ways together with the Websockets and for an advantages of Websockets with an introduction see An Introduction To WebSockets

这篇关于如何为 Web 应用程序推送通知(java/servlet)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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