Here is my Spring MVC controller code:
session.setAttribute("YourProperty", "arg1");
How can I access an attribute stored in an HttpSession using JavaScript?
I tried using this code:
var property = <%=session.getAttribute("YourProperty")%>; alert(property);
But it returns null.
thanks
var property="<%=session.getAttribute("MyProperty")%>"; alert(property);
Attribute names must match, and since you are adding a line, you must add "around <%=session.getAttribute("MyProperty")%>and the code will warn arg1.
"
<%=session.getAttribute("MyProperty")%>
arg1