title: Simple example to pass data back to Javascript
body: <p>How can I send data back to the JavaScript? For Example I just want to send "Hello World" to javascript using my servlet</p>
  
  <p>Servlet:</p>
  
  <pre><code>@Override
  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  
      String environmentName = request.getParameter("startEnvironment");
      String pause = Objects.toString(request.getParameter("pause"));
  
  
  if(pause == "true") {
     //I want to send a string "helloworld" back to javascript/ajax
  }
  </code></pre>
  
  <p>JavaScript / AJAX</p>
  
  <pre><code>   $(document).on('click','.pauseDocker' ,function(){
      var buttonClicked = $(this);
      var pauseEnvName = $(this).attr('name');
      console.log(pauseEnvName);
      //Run Docker
      $.ajax({
          type: 'post',
          url: 'DockerIntegration',
          data: {startEnvironment: pauseEnvName, pause: true},
          success: function () {
              buttonClicked.prop('disabled',true);
          },
          error: function() {
              alert("error");
          }
      });
  });
  </code></pre>