I was trying to populate collection(collection of items) from servlets to my jsp page..
In my servlet code I store the items in collection:
String itemsJson = new Gson().toJson(items);
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
response.getWriter().write(itemsJson);
In my jsp page I am tryin to populate the items onto a jquery resizable box.The code is as follows:
$(document).ready(function() {
$("#resizable").resizable();
$.getJSON('resizable', function(itemsJson) {
var $resizable = $('#resizable');
$.each(itemsJson, function(index, itemcatalog) {
$('<option>').text(itemcatalog.item).appendTo($resizable);
});
});
});
<div class="demo">
<div id="resizable" class="ui-widget-content">
<h3 class="ui-widget-header">Item List</h3>
<option></option>