Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Assign value to a variable

Hi,

Can anybody please tell me how to assign the value of Javascript variable to a JSP variable that was declared as global.

Suppose if 's' was a JSP variable and 'i' was a javascript variable, then how can i assign assign the value of 'i' to 's' and use 's' throughout my JSP page.

if possible can u give me example

Thanks in advance
[428 byte] By [subhakar_nani] at [2007-11-11 8:03:38]
# 1 Re: Assign value to a variable
You cannot assign a JavaScript variable to a JSP variable. JSP is server-side and JavaScript is client-side.

If you want your JSP variable to be set to that value, set the javascript varaible value to a hidden field and submit the form. request.getParameter() will give you the value and it can be assigned to a JSP variable. But I doubt if this would be worth the pains and submitting a form for this is unnecessary. There are other ways of designing code by which you should not need to do this at all.
aniseed at 2007-11-11 22:36:38 >