1

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.

Santhucool
  • 1,656
  • 2
  • 36
  • 92
  • @MaVRoSCy I found a useful article http://www.javabeat.net/asynchronous-servlet-servlet-3-0/. But I have doubt on this in example they are specifying on button click. If I do setInterval in place of button click does it make network load more? Please suggest buddy!! – Santhucool Nov 25 '15 at 07:10
  • did you tried `window.onload` or `document.onload` if you want to show pop up only once. – Vishrant Nov 25 '15 at 09:04

0 Answers0