Reputation: 11
I am trying to pass a string variable from my java class as follow:
request.setAttribute("fdata",fileName);
in order to send it to my jsp file as follow:
var fd ="0";
fd=<%= (String) request.getAttribute("fdata").toString()%>;
document.getElementById("reed").value = fd;
the problem is that the 'fileName' which is a string variable in java is converted to integer for example if I pass this string : "5-9" the result that i see in 'reed' textbox is (-4) or if i pass "8-7" the result will be (1) and if I pass something else e.g. "5-8dfs" it doenst show anything. I think my jsp file sees the string variable as integer variables and mathematical operators instead of String variable itself, any hint or suggestions ??
Thanks very much.
Upvotes: 0
Views: 307
Reputation: 1093
Your JavaScript string doesn't have quotes. I think you want to do this instead:
fd="<%= (String) request.getAttribute("fdata").toString()%>";
Upvotes: 1