javascript - Sending json data to next jsp page -
my problem follow : making ajax call jsp , getting json object comprising of flag , arraylist
jsp :
gson gson = new gson(); jsonobject root = new jsonobject(); root.addproperty("flag", flag); //add flag root.addproperty("list", gson.tojson(list)); out.println(gson.tojson(root));
now in success function of ajax function want move other jsp did :
success: function(response){ alert(json.stringify(response.list)); //alert(json.stringify(response.flag)); if(json.stringify(response.flag).indexof("true")>=0){ location.href="grouploginscreen.jsp"; } else{ alert("unsuccessful"); } }
now,the problem part though getting results here correct how send list argument in url grouploginscreen.jsp @ recieving end can obtained doing :
arraylist<string> list1 = (arraylist<string>)request.getattribute("mylist");
please help.
location.href="grouploginscreen.jsp" make new request browser in grouploginscreen.jsp, can't 'mylist' attribute did.
the solution you have encode list string using encodeuricomponent function add 'mylist' query parameter grouploginscreen.jsp.
the code this:
var mylistparam = encodeuricomponent ( json_text_of_the_list ); location.href = "grouploginscreen.jsp?mylist=" + mylistparam;
in grouploginscreen.jsp.
string mylist = request.getparameter("mylist"); convert mylist string arraylist
Comments
Post a Comment