Can I assign a Javascript variable to a JSP variable?
It is not possible to directly assign client side Javascript variables to JSP variables because the Java assignment is created when the JSP document is compiled into a servlet, before the output is served to the client. Javascript variables are created on the client side when a Web browser interprets a script. One way to pass Javascript values to JSP variables is to include them as query parameters for a JSP document. The JSP document can then get the values via the request.getParameterValues(String) method. When you pass Javascript variables in query parameters it is important to pass the value through the escape(String) method, as below. … full answer hidden, click here for all answers Actions: Follow-up or correct this answer. Submit a new question.