Reputation: 427
I am trying to reload webpage using location.reload(). I would also like to pass variable to this. I tried below option and it didn't work. Help plz?
location.reload(window.location.replace=("success.jsp?abc="+<%=processId%>));
I also tried directly using below code and it send the variable value. But after reloading the page, it didn't put the grid values on the page.if I reload directly using location.reload(), it works. However, it is not passing the variable.
window.location.replace=("grid.jsp?procid="+<%=processId%>)
Upvotes: 0
Views: 273
Reputation: 610
If you wish to do this in a simple cross browser compatible way, you have two options I can think of:
Use cookies (client side/Javascript)
Store whatever information you need inside of the browser using cookies. Most modern browsers and most users allow cookies these days, however there are still some that don't. There are examples here.
Use server side sessions (server side/Java)
I can see you're using JSP. I don't know Java that well, however this resource seems to have all the information for storing server side variables in a session. Once you've stored them, you can check if they exist on next page load and do whatever you need to.
Upvotes: 1
Reputation: 57322
You can persist data across page reloads via something like window.localStorage
, window.sessionStorage
or store values in cookies .
Upvotes: 1