0

I'm trying to retrieve the value of my setAttribute into my javascript code but I get a syntax error when I run the page.

Here is the code of my setAttribute in my servlet:

request.setAttribute("codeIGA", codeIGA); //a string is being passed here

Here is the code of my JS:

$(document).ready(
    function () {
        var count = 0;
        var lastCodeIGA =  ${sessionScope.codeIGA}; // syntax error here
        console.log(lastCodeIGA);
            .
            .
            . 
            etc

How can I retrieve the value from my servlet and input it into my JS?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Marielle
  • 81
  • 1
  • 2
  • 19

2 Answers2

0

You can use following to retrieve the required value.

var lastCodeIGA =  '${codeIGA}';
Jabir
  • 2,776
  • 1
  • 22
  • 31
-1

Try with scriptlet.

var test = <%=request.getAttribute("codeIGA");

Or

var lastCodeIGA = '${codeIGA}';
Vivek Kumar
  • 360
  • 1
  • 7
  • 16