0

i want to pass the hashmap object to another jsp to prepare the json data for me to create the grid.

in the jsp i am getting the hashmap from the dao java files but i need these hashmap contents to be displayed as a grid. so in order to do this i thought of passing it to another jsp which prepares the json data from hashmap. But i dont find any solution to pass the hashmap to that jsp file. i have to pass these hashmap as post values in grid. jsp file data

    Hashmap groupMap1= GroupMap.getGroupMapModel();
    Hashmap groupMap2 = GroupMap.getGroupMappingNames();

here is the code to create grid

            jQuery("#list").jqGrid({
                altRows:false
                ,autowidth:true
                ,url:'<%=request.getContextPath()%>/jsp/common/prepareGridData.jsp'
                ,datatype: "json"
                ,height: "100%"
                ,colNames:<%=colNames%>
                ,colModel:<%=colModel.toString()%>
                ,paging: true
                ,rowNum:25
                ,rowList:[25,50,75,100]
                ,loadonce:true
                ,caption: "Group Listing"
                ,pager:"#gridBottom"
                ,multiboxonly:false
                ,multiselect:false
                ,scrollrows:false
                ,shrinkToFit: false
                ,viewrecords:true
                ,postData:{groupMap1:"<%=groupMap1%>",groupMap2:"<%=groupMap2%>"}
            }).navGrid('#page',{edit:false,add:false,del:false});
        }

we cannot get any object thru request.getParameter. Then how can these values be accessed by prepareGrdData.jsp file to get the json data?

1 Answers1

0

One way may be set those as attribute, like request.setAttribute(key, value);

and

request.getAttribute(key);
kosa
  • 65,990
  • 13
  • 130
  • 167
  • is it possible to set and get the value in prepareGridData.jsp. because it is a post data to another jsp. we are not submitting the page. It is something like AJAX call. – user1470589 Jul 31 '12 at 20:44
  • If it is ajax call, may be you need to use something jQuery and JSON to send the Map content as JSON object. On Server end reconstruct Map object.http://stackoverflow.com/questions/11725661/passing-hashmap-from-javascript-to-servlet – kosa Jul 31 '12 at 20:45