JSP Value to JavaScript tells you to pass the value from JSP to JavaScript. The JavaScript create a function that accepts the value from the jsp page.
Understand with Example
In this section, we are going to pass the jsp value to javaScript. For this we have create a function addition() which takes the value from the jsp page. When a user click the button, the function addition is invoked and passed the values in order to add two numbers and then shows the result through the alert box.
Here is the code of passJspValue.jsp
| <%@ page language="java" %> <html> <head> <title> Pass value from JSP to JavaScript </title> <script language="JavaScript" > function addition(a,b) { var c=a+b; alert("The Addition of two numbers a and b is"+c); } </script> </head> Get the addition of two Numbers<br> <input type="button" onclick='addition(10,15);' value="Add"/> </html> |
Output will be displayed as:

On clicking the button, the alert box will show you the addition of two defined numbers:

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: JSP Value to JavaScript
Post your Comment