title: retrieve data from java servlet in a webpage
body: <p>I have a webpage which shows some info. In my webpage I have many coordenates (lon, lat) and I want to make a java class to ordenate these coords.</p>
  
  <p>Which I am trying to do is before showing coords, send them to the java servlet. This servlet would ordenate them and send back to the webpage to show them.</p>
  
  <p>I want that webpage doesn't refresh so I think I need ajax to call servlet, I have it more or less under control. But I don't know how to receive data in java from a webpage.</p>
  
  <p>I created some servlets in past but always calling java function using javascript. The problem of doing it by this way is that web browser goes to other webpage (jsp with java calls).</p>
  
  <p>I don't have yet the code for ordering coords but I am using this to try: </p>
  
  <pre><code>package ordenacion;
  
  public class OrdenarListaPuntos {
  
  
  public static String ordenar(String cadenaDesordenada){  //String unordered
      String cadenaOrdenada;
  
  //here goes the code for ordering
      cadenaOrdenada = cadenaDesordenada;
      return cadenaOrdenada; //String ordered
  }
  }
  </code></pre>
  
  <p>I just know how to call java function from javascript using jsp but not from other webpages in other servers or without refreshing webpage...</p>
  
  <p>Do you have any idea about how I should do it? Or what I should read about it?</p>