currently i am getting the static location when i click accept, but after clicking the accept the lat and lng should be refreshed for every 10sec. This is in a servlet. requestingclass.updatelocation(lat,lng); redirects to the data base class
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String bt = request.getParameter("action");
        ArrayList<String> rlist=new ArrayList<String>();
        if(bt.equals("refresh")){
        HttpSession session = request.getSession();
        String user =(String) session.getAttribute("uname");
        try {
            rlist=requestingclass.check(user);
            session.setAttribute("rlist", rlist);
            System.out.println(rlist);
            request.getRequestDispatcher("main.jsp").forward(request, response);
        } catch (ClassNotFoundException | SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
        if(bt.equals("accept")){
            ScheduledExecutorService scheduler=Executors.newScheduledThreadPool(1);
            String lat=request.getParameter("latlocation");
            String lng=request.getParameter("lnglocation");
            requestingclass.updatelocation(lat,lng);        
        }
    }
edit 1: this has to be run in a servlet which is perdefined
 
    