Nested If Statement
In this section you will study about the Nested-if Statement in jsp.
Nested If statement means to use the if statement inside the other if statement. Here we are providing you an example using Nested-If statement. In the example, we want to display the reciprocal of a number only if that number is positive. So, an integer variable number is initialized to 4.
Here is the code of nestedIf.jsp
| <HTML> <HEAD> <TITLE>Nested if Statement Example</TITLE> </HEAD> <BODY> <H2>Nested if Statement Example</H2> <% double number = 4; if (number != 0) { if (number> 0){ out.println("The result = " + (1 / number)); } else out.println("A positive number is required."); } %> </BODY> </HTML> |
Output will be displayed as:

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: Nested If Statement View All Comments
Post your Comment