0

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.

1 Answer 1

1

Your JavaScript string doesn't have quotes. I think you want to do this instead:

fd="<%= (String) request.getAttribute("fdata").toString()%>";
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.