title: How to return json object from jsp to angularjs ajax http.get?
body: <p>When I run the jsp file I get [{"USRNM":"sahar","USRPWD":"password"}] which is correct but when I run html I cant display the data and when I alert it I get the data inside html tag while I tried with json file which alerts data in the form of [object object].please help me to find out what I am doing wrong.</p>
  
  <p>jsp:</p>
  
  <pre><code>    Statement stmt = con.createStatement();
  
      ResultSet rs = stmt.executeQuery("select UsrNm,UsrPwd from dbo.tblUsr"); 
  
  
      ResultSetMetaData rsMetaData = rs.getMetaData();
  
      int numberOfColumns = rsMetaData.getColumnCount();
      JSONArray jsonArray = new JSONArray();
      //List &lt;JSONObject&gt; jsonArray = new ArrayList&lt;JSONObject&gt;();
        List &lt;String&gt; columnNames = new ArrayList&lt;String&gt;();
          for(int i=1;i&lt;=numberOfColumns;i++) {
          columnNames.add(rsMetaData.getColumnName(i).toUpperCase());
      } 
       while(rs.next()) {
           JSONObject obj = new JSONObject();
           for(int i=1;i&lt;=numberOfColumns;i++) {
              String key = columnNames.get(i - 1);
              Object value = rs.getObject(i);
              obj.put(key, value);
           }
  
      jsonArray.add(obj);
       }
  
       //response.setContentType("application/json");
         // response.setCharacterEncoding("UTF-8");
         response.getWriter().write(jsonArray.toString());
  </code></pre>
  
  <p>html:</p>
  
  <pre><code>  &lt;script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
    &lt;body&gt;
  
      &lt;div ng-app="myApp" ng-controller="customersCtrl"&gt;
  
     &lt;table&gt;
     &lt;tr ng-repeat="x in names"&gt;
     &lt;td&gt;{{ x.USRNM}}&lt;/td&gt;
     &lt;td&gt;{{ x.USRPWD}}&lt;/td&gt;
     &lt;/tr&gt;
     &lt;/table&gt;
     &lt;/div&gt;
  
     &lt;script&gt;
          var app = angular.module('myApp', []);
          app.controller('customersCtrl', function($scope, $http) {
          $http.get("newjsp2.jsp")
                .success(function (response) {
                // alert(JSON.stringify(response));
                alert(response);
                $scope.names = response;
          }).error(function(response,status,headers,config){
                alert('cannot find resource');
                console.log(response);
                console.log(status);
                console.log(headers);
                console.log(confiq);
           }); 
     });
     &lt;/script&gt;
  </code></pre>