title: how can I do ajax call to fetch data from database in jsp using Extjs?
body: <p>I am using Extjs framwork. First I create a servlet to get data from database. After getting data from database I am storing in a list. Then I am converting the list into json array.Now I want to get these data into jsp page using Extjs ajax call. how can I do that?
  My servlet is </p>
  
  <pre><code>String str = "select * from employee";
                      rs = stmt.executeQuery(str);
                      List&lt;Employee&gt; list1 = new ArrayList&lt;Employee&gt;();
                      while(rs.next){
                          emp = new Employee();
                          emp.setEmpId(rs.getInt(1));
                          emp.setFirstName(rs.getString(2));
                          list1.add(emp);
                      }
                      Gson gson = new Gson();
                      JsonElement element = gson.toJsonTree(list1, new TypeToken&lt;List&lt;Employee&gt;&gt;() {
                      }.getType());
                      JsonArray jsonArray = element.getAsJsonArray();
                      response.setContentType("application/json");
                      response.getWriter().print(jsonArray);
  </code></pre>
  
  <p>Now I am calling this servlet in jsp file on click of button through Extjs. How can I do ajax call? I am using this..</p>
  
  <pre><code>    Ext.onReady(function () {
      Ext.create('Ext.Button', {
          text: 'click',
          handler: function () {  
              Ext.Ajax.request({
             url: 'TestEmployee',
         success: function(result, request) {
        /////what shold I do here so that I get data here and display in jsp???
     },
     failure: function(response, opts) {
        Ext.MessageBox.alert('Failed', result.responseText);
     }
  });
          },   
          renderTo: Ext.getBody()
  
      });
      });
  </code></pre>