title: Sending data from servlet to android application with JSON
body: <p>Good night,</p>
  
  <p>I'm trying to send from a servlet written in Java data name in a JSON to an application in Android.</p>
  
  <p>Not that I'm doing wrong but when it comes to mobile text comes a strange text.</p>
  
  <p>Below I describe the code:</p>
  
  <p>servlet:</p>
  
  <pre><code>if (opcion.equals("4")){//Devolver nombre, apellidos y DNI de Usuario
  
          String usuario = request.getParameter("login");
          Usuario user = facade.getUsuarioByLogin(usuario);
  
          String nombre= user.getNombre();
          String apellidos = user.getApellidos();
          String dni = user.getDni();
  
          System.out.println("El valor de Nombre es"+nombre);
  
  
          response.setContentType("application/json");
  
          JSONObject json = (JSONObject) JSONSerializer.toJSON( nombre );
  
          //System.out.println("El valor de json"+json.toString());
          out.println(json);
  
          out.close();
      }
  </code></pre>
  
  <p>Piece of Android application code that gets the JSON (I ignored the try catch to make the code more readable):</p>
  
  <pre><code>HttpClient cliente = new DefaultHttpClient();
  
      HttpPost post = new HttpPost (url.toString());
  
  
      ResponseHandler&lt;String&gt; handler = new BasicResponseHandler();
  
      List&lt;NameValuePair&gt; elementos = ele;
  
  
          post.setEntity(new UrlEncodedFormEntity(elementos));
  
      HttpResponse respuesta = null;
  
          respuesta = cliente.execute(post);
  
  
      Log.i("Prueba", "El valor de respuesta es "+respuesta.toString());
  </code></pre>
  
  <p>I thought that respuesta should have the JSON that servlet sends me but it returns a  text which does not contain the name</p>
  
  <p>Do you see something you do wrong?</p>
  
  <p>Greetings and thanks</p>