title: Pushing real-time data from Spring MVC Controller
body: <p>i've made a simple Rest android Client which send a request  to A Spring mvc controller.</p>
  
  <p>This is the android code</p>
  
  <pre><code>package security.com.testing;
  
  import android.os.AsyncTask;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  
  import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
  import org.springframework.web.client.RestTemplate;
  
  import java.util.HashMap;
  import java.util.Map;
  
  
  public class MainActivity extends AppCompatActivity implements View.OnClickListener {
      private EditText editTextName;
      private EditText editTextUsername;
      private EditText editTextPassword;
      private EditText editTextEmail;
  
      private Button buttonRegister;
      //This is our root url
      public static final String ROOT_URL = "http://192.168.1.68/";
      private Map&lt;String, String&gt; vars;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          vars = new HashMap&lt;String, String&gt;();
          vars.put("id", "JS01");
          new HttpRequestTask().execute();
  
      }
  
  
      //Overriding onclick method
      @Override
      public void onClick(View v) {
          //Calling insertUser on button click
  
      }
  
  
      private class HttpRequestTask extends AsyncTask&lt;Void, Void, User&gt; {
          @Override
          protected User doInBackground(Void... params) {
              try {
                  final String url = "http://192.168.88.1:8080/api/{id}";
  
                  User u = new User();
                  u.setName("Johnathan M Smith");
                  u.setUser("JS01");
  
  
                  RestTemplate restTemplate = new RestTemplate();
                  restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
                  User us = restTemplate.postForObject(url, u, User.class, vars);
                  return us;
              } catch (Exception e) {
                  Log.e("MainActivity", e.getMessage(), e);
              }
  
              return null;
          }
  
          protected void onPostExecute(Greeting greeting) {
          }
  
      }
  
  }
  </code></pre>
  
  <p>My MVC Controller Accepts the android Request(User object ) with success.</p>
  
  <p>Here is my Mvc Controller Code</p>
  
  <pre><code>import org.springframework.stereotype.Controller;
  import org.springframework.ui.Model;
  import org.springframework.web.bind.annotation.*;
  
  @Controller
  @RequestMapping("/api")
  public class GreetingController {
  
      @RequestMapping(value = "/{id}", method = RequestMethod.POST)
      @ResponseBody
      public String updateCustomer(@PathVariable("id") String id, @RequestBody User user,Model model) {
          System.out.println("I am in the controller and got user name: " +user.getName());
          model.addAttribute("name", user.getName());
          return "result";
      }
  }
  </code></pre>
  
  <p><p>My problem now is that i want to update the browser when Mvc controller accepts the value of the request in real time. The request going through every 3 min and i want the browser be notified(when Mvc controller accepts requests) . How should i do this?.i am not sure but i think i should use reverse ajax or cometd. Can you help me achieve it,sorry for my stupid question but i am so confused and i can't find the proper way to solve my problem.<p></p>