1

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

M. Deinum
  • 94,295
  • 20
  • 185
  • 191
  • please try to provide a [Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) – mightyWOZ Jan 08 '20 at 09:33
  • no my request is to just loop it when a user clicks the button accept it is forwarded to servlet and his location gets updated into database for every 10 sec.@amongalen – gopal krishna mareti Jan 08 '20 at 10:01

0 Answers0