title: How to run my javascript functions in Java class implemented runnable?
body: <p>My java-script function with ajax which has to be moved in to a java class:-</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
  
  
  
  $(document).ready(function(){
  
  
  var polyLat = new Array();
  polyLat[0] = 10.194027;
  polyLat[1] = 10.226975;
  polyLat[2] = 10.059987;
  polyLat[3] = 10.002248;
  polyLat[4] = 9.854925;
  polyLat[5] = 9.835443;
  polyLat[6] = 9.899107;
  polyLat[7] = 9.993088;
  polyLat[8] = 10.081425;
  polyLat[9] = 9.992266;
  polyLat[10] = 10.194027;//First point repeated to close polygon
  var polySides = (polyLat.length)-1;//number of points in polygon
  //vertical Longitude coordinates of polygon 
  var polyLng =  new Array();
  polyLng[0] = 76.201205;
  polyLng[1] = 76.375022;
  polyLng[2] = 76.775730;
  polyLng[3] = 76.778940;
  polyLng[4] = 76.584336;
  polyLng[5] = 76.411473;
  polyLng[6] = 76.368070;
  polyLng[7] = 76.397007;
  polyLng[8] = 76.317492;
  polyLng[9] = 76.267905;
  polyLng[10] = 76.201205;//First point repeated to close polygon
  //Coordinates for bounding box
  var maxLat = Math.max.apply(null,polyLat);  
  var minLat = Math.min.apply(null,polyLat);
  var maxLng = Math.max.apply(null,polyLng);
  var minLng = Math.min.apply(null,polyLng);
  
  
  $.post('outboundupd.jsp',
          {
      mx_lat:maxLat,
      mn_lat:minLat,
      mx_lng:maxLng,
      mn_lng:minLng,
      ply_sds:polySides
          },
          function(response,status,xhr)
          {
  //          alert(response.trim());
              plotdata(response);
  
  
  });
  
      function plotdata(response)
      {
          var x;
          var y;
          var mob;
          var jsonArray=JSON.parse(response.trim());
          var jalen= jsonArray.length; 
          for(i=0;i&lt;jalen;i++)
          {
              var obj=jsonArray[i];
              pcode= obj.Pcode;
              nplate= obj.N_plate;
              driver= obj.Driver;
              mob= obj.MobileNu;
              x= obj.Latitude;
              y= obj.Longitude;
              time= obj.Time;
  
          }
  
  
          var j = polySides-1 ;
            oddNodes = 0;
            for (i=0; i&lt;polySides; i++) {
              if (polyLng[i]&lt;y &amp;&amp; polyLng[j]&gt;=y  ||  polyLng[j]&lt;y &amp;&amp; polyLng[i]&gt;=y) {
                  if (polyLat[i]+(y-polyLng[i])/(polyLng[j]-polyLng[i])*(polyLat[j]-polyLat[i])&lt;x)  {
                      oddNodes=!oddNodes; 
                  }
              }
             j=i; }
  
  
  
  
              if(oddNodes!=true)
              {
  //              alert("ob mobile:"+mob);
  
                  $.post('obsouth.jsp',
                          {
  
                      pcd:pcode,
                      npt:nplate,
                      drv:driver,
                      mobl:mob,
                      lat:x,
                      lon:y,
                      tm:time
  
                          },
                          function(response,status,xhr)
                          {
                              alert(response.trim());
  
  
                  });
  
              }
  
            return oddNodes;
  
  
          }
  
  });
  
  &lt;/script&gt;
  </code></pre>
  
  <p>I need the above code to be executed periodically after server start, so i had used context listner and implemented runnable in a new java class, below is my java class:-</p>
  
  <pre><code>package com.my.classes;
  
  public class obrecord implements Runnable {
  
      @Override
      public void run() {
          // TODO Auto-generated method stub
  
      }
  
  }
  </code></pre>
  
  <p>Now, i need to execute the above javascript code in the below java class to run it periodically on server start. is there any method to do it? or is there any alternative efficient method to get the job done?  Any piece of code is highly appreciated and thanks in advance.</p>