Passing JSON object from Controller to View(jsp)

Posted by user752233 on Stack Overflow See other posts from Stack Overflow or by user752233
Published on 2011-05-13T11:01:26Z Indexed on 2012/09/22 21:38 UTC
Read the original article Hit count: 179

Filed under:

I am trying to send JSON object to my view from controller but unable to send it. Please help me out!

I am using following code

public class SystemController extends AbstractController{

    protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
        ModelAndView mav = new ModelAndView("SystemInfo", "System", "S");

        response.setHeader("Cache-Control", "no-cache");
        JSONObject jsonResult = new JSONObject();

        jsonResult.put("JVMVendor", System.getProperty("java.vendor"));
        jsonResult.put("JVMVersion", System.getProperty("java.version"));
        jsonResult.put("JVMVendorURL", System.getProperty("java.vendor.url"));
        jsonResult.put("OSName", System.getProperty(""));
        jsonResult.put("OSVersion", System.getProperty("os.version"));
        jsonResult.put("OSArchitectire", System.getProperty("os.arch"));

     //   response.getWriter().close();

        return mav;             // return modelandview object

and in the view side I am using

<script type="text/javascript">

Ext.onReady(function(response) {
     //Ext.MessageBox.alert('Hello', 'The DOM is ready!');
     var showExistingScreen = function () {
            url                     : 'system.htm',
            method                  : 'POST',
            scope                   : this,
            success: function ( response ) {
                var existingValues = Ext.util.JSON.decode(response.responseText);

    return showExistingScreen();

© Stack Overflow or respective owner

Related posts about spring-mvc

Related posts about view