I have a jsp page that communicate with a servlet back end. Up until now, the way I communicate with that servlet is via .getJSON() which is a JQuery method. This work great if
Just have the data in a collection or map of fullworthy Javabeans and make use of Google Gson to convert it to JSON without any pains. JSON is more compact than XML and much easier to process in JavaScript (it's also the JavaScript Object Notation).
All you basically need to do with help of Gson is the following:
List<Data> list = dataDAO.list();
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
response.getWriter().write(new Gson().toJson(list));
That's all. I've answered this several times before with examples: here, here, here, here and here.