0

I am trying to make a Ajax call from my JSP and generating a ArrayList of a business object in the servlet. Now I don't know how to iterate the list and populate the BO in JSP.

My code as below:

Servlet code :

ArrayList<TestBO> ajaxList = new ArrayList<>();
TestBO bo = new TestBO();
bo.setName("Name1");
bo.setAdress("Kolkata");
bo.setMobile("909090000");
ajaxList.add(bo);

bo = new TestBO();
bo.setName("Name2");
bo.setAdress("Delhi");
bo.setMobile("808000000");
ajaxList.add(bo);

PrintWriter out = response.getWriter();
out.print(ajaxList);
out.close();

JSP code :

$.ajax({
     type: 'GET',
     url: '/TestWeb/AjaxServletList',
     datatype:'text',
     success: function(data) {
         alert(data);
         var values = [];
         values = data;    
     }
});
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Bhabani Shankar
  • 1,267
  • 4
  • 22
  • 41

0 Answers0