var s = "<%=str%>";
In the source you would have seen: var s=Raja;
Instead of: var s = "Raja";
And Vijesh is correct. Declaring the string as an instance variable not only wouldn't have helped in this case, it most likely would have lead to threading problems in the application.