title: How to send a custom java class object as response to a ajax call in java servlet and retrieve it back in javascript?
body: <p>I have a java class as follows.</p>
  
  <pre><code>Class GrosBean{
      private Map&lt;Integer,String&gt; ItemList;
      private ArrayList&lt;String&gt; selectItemList;
  
      public Map&lt;Integer, String&gt; getItemList() {
          return ItemList;
      }
      public void setItemList(Map&lt;Integer, String&gt; ItemList) {
          this.ItemList = ItemList;
      }
      public ArrayList&lt;String&gt; getSelectItemList() {
          return selectItemList;
      }
      public void setSelectItemList(ArrayList&lt;String&gt; selectItemList) {
          this.selectItemList = selectItemList;
      }
  
  }
  </code></pre>
  
  <p>I make a call to a servlet using ajax and this respective servlet fetches data from database and put into object of above class. Finally I have object of above GrosBean filled with data in it.</p>
  
  <p>I want to send this data back to calling page javascript code.</p>
  
  <p>I want to retrieve back this object in javascript and construct list of check boxes with the values in this object.</p>
  
  <p>How do I send the java class object as ajax response using json and iterate through its list and map properties in javascript?</p>
  
  <p>Please guide me in this friends.</p>
  
  <p>Thank you in advance!</p>