In controller, I have set session attribute
HttpSession session = request.getSession(); session.setAttribute("Anshu", true);
In JSP,I am trying to get value from session
<input type=hidden id=file value="${sessionScope.Anshu}" />
In JavaScript,trying to display that value..
var nish=document.getElementById("file").value; alert(nish.value);
But, when I am trying to run the code ,I am getting 'Undefined' in alert statement. Can anyone tell me whay its coming 'undefined' ? Thanks in advance ! :-)
the problem is this: <input type=hidden id=filevalue="${sessionScope.Anshu}" />
it should be like this:
<input type="hidden" id="file" value="${sessionScope.Anshu}" />
plus in your javascript code you don't have to say .value
twice. once is enough.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments