I am using Servlet, JSP and JQuery
combination in my application. What I need as follows:
I have a page Home.jsp
and insert.jsp
. Home.jsp
is the home page and insert.jsp
is the page from where I am inserting values into database. I am using Postgresql 9.5
as DB.
My requirement is that When ever I insert a value in database using insert.jsp
page then I should get notification on my Home.jsp
page.
I am making use of bootstrap
as well for UI .
What I do is as follows:
setInterval(function() {
$.get("TestServlet", function(data){
if(data.trim() == "0"){
console.log("if");
}else{
$('#myModal').modal('show');
}
});
}, 5000);
My TestServlet
will return the no: of records in that table. So when ever the user entered home page it will alert bootstrap modal
as notification. And it keeps on coming every 5 seconds after first entry but I need it should come once
.
Is there any alternate ways for notification? Or any other real time methods using the default Servlet
methods? please guide me.