Reputation: 1
In javascript function: stored value in localStorage using this line
localStorage.setItem("Phrase","Hello Tech");
And want to display Phrase's value in jsp file:
localStorage.getItem("Phrase");
But it's showing me this full sentence, not a value of it. Could anyone help me with this? Thank you in advance.
Upvotes: 0
Views: 8548
Reputation: 2924
You have to realize, where and when which code is executed - JSP on the server when the page is requested and rendered (i.e. before the response is sent to the browser) and Javascript in the browser, after the browser receives the already generated response.
The localStorage
is browser-side thing, JSP has no access to it. I.e. in JSP you can only generate JS code to access localStorage
, but this code will be executed by the browser.
Upvotes: 2