Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a JSP code like below having var x and I have added a scriptlet inside function and want access x in scriptlet. But getting errors while accessing, please let me know how to access x inside scriptlet?

What I have tried:

JavaScript
function checkfrm(obj)
{
    var x = obj.number.value;

   <%
        String value = "Number is "+x; // not working here
   %>
}
Posted
Updated 22-Jan-21 4:42am
v2

1 solution

Your Javascript function runs on the client, long after your JSP code has finished executing. You cannot access client-side variables from server-side code in this way.

You will need to find another solution to the problem you're actually trying to solve.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900