0

I tried declaring the variable in my JSP:

<script> var _csrf.token = "${_csrf.token}"; </script>

And then accessed it in my ts file in this code, below, it displayed the value correctly.

console.log(window['_csrf.token']);

However, I am getting an undefined on this scenario, my purpose is to hide it in the browser for security purpose.

I have this code on JSP

<c:set var="_csrf.token" value="${_csrf.token}" />  

And tried to access on Angular .ts file using this code.

console.log(window['_csrf.token']);

Am I correct with using the jstl tag or not? I don't really know how. Can someone teach me how to get the value from the jsp to ts file?

DaLoco
  • 191
  • 2
  • 3
  • 9
  • @BalusC by the way, concern with putting it in – DaLoco Aug 16 '17 at 07:53
  • It returns undefined because it isn't defined as a JS variable. You have nowhere written `window['_csrf.token'] = "${_csrf.token}";` in JavaScript. – BalusC Aug 16 '17 at 08:02
  • @BalusC i updated the question. kindly read it if do we have the same scenario because i dont know how. thanks – DaLoco Aug 16 '17 at 08:13
  • `window['_csrf.token']` is not the same as `var _csrf.token`. This is basic JavaScript. – BalusC Aug 16 '17 at 09:08

0 Answers0