ajax - how do we use request.session.setAttribute for already existing session variable to UI -


while loading view page setting session variable as:

request.session.setattribute("list",list); 

after onclick of button using ajax call refresh list. in backend able see latest list contents. in ui using :

list<string> clist = (list<string>)session.getattribute("list"); 

but after list changed not able see latest list contents.still old list contents displaying on page. need suggestions on how resolve issue.

var refreshthisdiv= "refreshthisdiv";             var gourl= "unametest/getusernameslist;             var httprequest=null;             var refreshcontent = "null";             httprequest = xmlhttpobject();             httprequest.open("post", gourl, true);             httprequest.onreadystatechange = function () {ajaxfcuntion(refreshthisdiv,httprequest); } ;             httprequest.setrequestheader('content-type', 'application/x-www-form-urlencoded');             httprequest.send(null);  //ajaxfcuntion function ajaxfucntion(refreshthisdiv,httprequest){      if (httprequest.readystate == 4)     {         if(httprequest.status == 200)         {             results =  httprequest.responsetext;  if(results!=null){              <%              list<string> list = (list<string>)request.getsession().getattribute("list"); %> //display data list } 

}

actually expected, mixing 2 different codes. have realize, where , when each code executed - jsp on server when page requested , rendered (i.e. before response send browser) , javascript in browser, after browser receives already generated response. more details how use ajax, jsp , servlets together, read this question , answer carefuly.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -