Home Jsp Nested If Statement



Nested If Statement
Posted on: August 5, 2008 at 12:00 AM
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.

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:

Download source Code

Related Tags for Nested If Statement:
cideantintegervariablenesteddisplayipvinumberstateusingintriaidifexamplestatementtoiniexamposciproceitliinitsplvaruseinitializeincalstamntplaysidsidewanososicaosiosispesempositivememeanproxaxampsspsoatnested-ifishaivmpleaarstatwantvazssrocrithstabablhatdispinitialpleplpronlyononl


More Tutorials from this section

Ask Questions?    Discuss: Nested If Statement   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

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.