If else is used in most programming languages in this way. Today we will briefly introduce the if else and multi-condition judgment in the jsp tutorial.
<HTML>
<HEAD>
<TITLE> Using the if Statement </TITLE>
</HEAD>
<BODY>
<H1> Using the if Statement </H1>
<%
Int value = 10;
If (value> 0)
Out. println ("Absolute value of" + value + "=" + value );
%>
</BODY>
</HTML>
Simple comparison
<HTML>
<HEAD>
<TITLE> Using Compound Statements </TITLE>
</HEAD>
<BODY>
<H1> Using Compound Statements </H1>
<%
Int value = 10;
If (value> 0 ){
Out. println ("The number was positive .");
Out. println ("Absolute value of" + value + "=" + value );
}
%>
</BODY>
</HTML>
If else
<HTML>
<HEAD>
<TITLE> Nested if Statements </TITLE>
</HEAD>
<BODY>
<H1> Nested if Statements </H1>
<%
Double value = 2;
If (value! = 0 ){
If (value> 0)
Out. println ("The result =" + (1/value ));
Else
Out. println ("Sorry, we need a positive number .");
}
%>
</BODY>
</HTML>
Multiple conditions, if else
<HTML>
<HEAD>
<TITLE> Using an if-else Ladder </TITLE>
</HEAD>
<BODY>
<H1> Using an if-else Ladder </H1>
<%
String day = "Friday ";
If (day = "Monday ")
Out. println ("It's Monday .");
Else if (day = "Tuesday ")
Out. println ("It's Tuesday .");
Else if (day = "Wednesday ")
Out. println ("It's Wednesday .");
Else if (day = "Thurssday ")
Out. println ("It's Thursday .");
Else if (day = "Friday ")
Out. println ("It's Friday .");
Else if (day = "Saturday ")
Out. println ("It's www.111cn.net/5230/ Saturday .");
Else if (day = "Sunday ")
Out. println ("It's Sunday .");
%>
</BODY>
</HTML>