Home Jsp Nested If Statement

Related Tutorials


 
 

Share on Google+Share on Google+

Nested If Statement

Advertisement
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

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: August 5, 2008

Related Tutorials

Discuss: Nested If Statement   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:2
Jiezelle Gonzales
December 7, 2011
IT 215

I hope I can learn this kind of programming especially to their syntax error..........,Its nice this for us to know hot to program some of presentation or event when we have a job soonly....,I hope I can pass my NCIV this coming 2012............,
chanelle biangco
September 18, 2012
computer

hey!thank you sa mga meaning!!!i can surely uswe this in my assignment in computer
DMCA.com