Reputation: 83
I am in the process of spring-mvc project. Login page is currently in progress. The problem is, I don't know how to use the SessionStorage
function in JSP
. I need to retrieve the data I saved in the SessionStorage
.
I'm saving the ID value after I log in.
Login.js
sessionStorage.setItem("Email",data.email);
It's where I have to use it.
Header.jsp
<a href="#" class="dropdown-toggle" data-toggle="dropdown" ><i class="fa fa-user"></i> <span >/****sessionStorage.getItem() ***/</span></a>
I've already saved and tried the session on the controller, but it didn't work.
controller.java
session.setAttribute("id", email);
<a href="#" class="dropdown-toggle" data-toggle="dropdown" ><i class="fa fa-user"></i> <span > <%session.getAttribute("id");%></span></a>
I need your solution. help me a lot
Thanks in advance.
Upvotes: 1
Views: 4103
Reputation: 13926
Write JavaScript phrases using <script />
.
First, save to an object in SessionStorage
, and read the object you have saved.
<a href="#" class="dropdown-toggle" data-toggle="dropdown" ><i class="fa fa-user"></i>
<span >
<script type="text/javascript">
window.sessionStorage.email = sessionStorage.getItem("Email")
document.write(window.sessionStorage.email)
</script>
</span>
</a>
Upvotes: 1