How to parse JSON object at jsp

I wauld parse JSON object(List) which the i pass from controller. I want to convert my JSON object in html, but I want to extract each parameter separately.

@JsonView(View.Public.class)
@RequestMapping(value = "/updatecomments", method = RequestMethod.GET)
@ResponseBody
public List<Commentary> updateCommentary(@RequestParam int idEvent) {
    System.out.println("updatecomm: " + idEvent);
    Event event = eventService.findById(idEvent);
    List<Commentary> comments = event.getComments();
    return comments;
}

when i parse with this function it’s work:


    function updateComments() {
        $.ajax({
            url : "/updatecomments",
            method : 'GET',
            data : {
                idEvent: ${event.getId()},
            },
            dataType : 'json',
            success : function(results){
                alert("succes");
                var json = "

Ajax Response

"
                    + JSON.stringify(results, null, 4) + "

";
$('#feedback').html(json);
}
});
};

but when i would parse with this code, it isn’t work:


    function updateComments() {
        $.ajax({
            url : "/updatecomments",
            method : 'GET',
            data : {
                idEvent: ${event.getId()},
            },
            dataType : 'json',
            success : function(results){
                alert("succes");

                
                    alert(${comment.description});
                    alert(1);
                
            }
        });
    };

This function also does not work

var comments = $.parseJSON(results);

What is my mistake?


Source: stackoverflow-javascript

Get the value of an hidden input from a JSP page [Angular JS]

I am working with JSP and Angular JS. I have a JSP page with a hidden input field. a session attribute is set to its value as follows.

  String policy = (String)session.getAttribute("POLICY_CHANGE");

  <input type="hidden" value="<%=policy%>" name="ng2_session" ng-modal="vm.policyChange" />

How can i bind the value of the input field to a variable $scope.policy in my controller.

JS

var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
   $scope.policy = ; // i want to bind the input field value here.
});


Source: stackoverflow-javascript