How Do You Assign Javascript Variable To Session Variable In Javascript Method With Coding Explain Detaily In Jsp?
I’ll do my best to answer this, but the question isn’t 100% clear. The important thing to realize is that Javascript (I’ll use JS for short) is executed on the client (in the browser), and JSPs are executed on the server. The JSP generates the HTML page, including all of the JS code. So the answer to #2 is trivial, when you use JSP to create an HTML page and JS code, just create a JS variable as part of the page that you are creating. You might alternatively create some form elements and assign the variable that you are interested in there. For example, using the form element. Then javascript can access this hidden form element using myForm.hidden. Now, to pass a variable from JS back to the server where your JSP is executing, you need to post a form. JS allows you to submit a form proramatically (check out tutorials on the web such as at w3schools.com). In your JSP that is executed you will use the Request.get(“myVariable”) to get the values of the