What you are doing is fine.
var s = "<%=str%>";
The best way to get your head around this is to view the HTML source from your browser often.
In the source you would have seen:
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.
Originally posted by Muthiah Raja:
For that i use the follwing code
<% String str="Raja"; %>
But this code is not worked.
Instead of writting var s=<%=str%>;
I try var s='<%=str%>';
I try var s="<%=str%>";
this code also not worked.
Kindly help me.
It works for me: