jsp - Javascript variables should retain same value of a variable,declared and initialized before -


i need save value of variable in javascript declared , assigned value during previous call function in javascript. both declaring , initializing variable once, need value of variable when needed. there way store value of variable , retrieve it, time needed??

p1.jsp

<table>      <%         for(i=0;i<g;i++){            request.getsession().setattribute("incr",i);      %>      <tr><td><jsp:include page="/p2.jsp" /></tr></td>      <%}%> </table> 

p2.jsp

 <%!int i;%>     <%       i=request.getsession().getattribute("incr");     %>     <script type='text/javascript'>     var k<%=i%>;     function d(){          k<%=i%>=5;     }     </script> 

//here, need print k0,k1,.... value needed

use sessionstorage or localstorage save data need. example:

sessionstorage.setitem("variable",value); 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -