I am using java and jsp for my project. I have developed a facebook like notification icon. I am doing a servlet URL call by jQuery. Servlet checks the value in DB and return the result. This call interval is 1 second. Ex.-
<div id="noti_Container">
    <a href="layoutMailbox.jsf"> 
        <img src="#{resource['images:Network.png']}"
        alt="Notifications" style="width: 25px;" />
</a>
<div id="check" class="noti_bubble">2</div>
    <script>
        var int=self.setInterval(function(){clock()},1000);
        function clock()
        {
            $.get('Servlet URL', function(responseText) {
                    document.getElementById("check").innerHTML = responseText;
                    });
        }
    </script>
</div>
But this could be a "heavy" approach because it pings Servlet every second and doing the DB-interaction.
Is there any alternative to update count of Notifications if DB gets updated?
 
     
     
     
    