I have a java file by which I want to pass map something like : { id: 5, GPA: 5} to my jsp file using AJAX. I am using following code for this:
In my JAVA file:
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
JSONObject jsonResult = new JSONObject();
jsonResult.put("id", "5");
jsonResult.put("GPA", "5");
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
response.getWriter().write(jsonResult.toString());
}
In jsp file: --some extJS code--
Ext.Ajax.request({
url :'assertion.htm',
method : 'POST',
params: {
existingRule : nameField.getRawValue()
},
scope : this,
success: function ( response ) {
alert(response.responseText);
}
response.responseText is printing entire jsp file instead of printing id:5, GPA:5 Can anyone help me in this?