0

I have a servlet that is supposed to return a report to a web page, each item in the report is stored in the alist List object.

out.println(alist); // ArraList of String

On the client-side, here is the Javascript code that captures the data from alist:

$.get('DisplayReport',{reportId:reportId},function(responseTest){
    $("#div1").show();
    for(var i = 0; i < responseTest.length; i++)
    {
        $('#row1').append("<td>"+responseTest[i]+"</td>");
    }
});

The problem is that responseTest[i] displays each character instead of each item in the list. Please help.

the_marcelo_r
  • 1,847
  • 22
  • 35
Nirmallya Ghosh
  • 11
  • 1
  • 1
  • 5
  • Dude... a Java list can't be converted to a Javascript list. Take a look at this: http://stackoverflow.com/questions/2010990/how-do-you-return-a-json-object-from-a-java-servlet – the_marcelo_r Oct 28 '14 at 18:53
  • what i need to send or write in out.println() , which i can pick from $.get success method – Nirmallya Ghosh Oct 28 '14 at 18:59
  • Can't you convert `ArrayList` object to Json? – SK. Oct 28 '14 at 19:07
  • [See this 1](http://stackoverflow.com/questions/15332733/how-to-convert-list-data-into-json-in-java) [See this 2](http://stackoverflow.com/questions/14228912/how-to-convert-list-to-json-in-java) – SK. Oct 28 '14 at 19:08
  • what i will pass from servlet to $.get('servlet') – Nirmallya Ghosh Oct 28 '14 at 19:26

0 Answers0