Apekshit
  • Home
  • Tutorials
  • Interview Questions
  • About
  • Contact
  • Core JAVA
  • JSP
  • JSTL
  • JDBC
  • Algorithms
  • HTML
  • SQL
  • JavaScript
  • JSP Tutorial
    • JSP Introduction
    • JSP in Eclipse
    • JSP Scripting Elements
    • JSP Directives
    • JSP Page Directive
    • JSP Taglib Directive
    • JSP Include Directive
    • JSP Forward Tag
    • JSP Redirect
    • JSP Forward Vs Redirect
    • JSP Include Tag
    • JSP UseBean Tag
    • JSP SetProperty
    • JSP GetProperty
    • JSP Implicit Objects
    • JSP Request Object
    • JSP Response Object
    • JSP pageContext Object
    • JSP session Object
    • JSP out Object
    • JSP application Object
    • JSP config Object
    • JSP Scopes
    • JSP Page Scope
    • JSP Request Scope
    • JSP Session Scope
    • JSP Application Scope
    • JSP Output Comment
    • JSP Hidden Comment
  • JSTL Tutorial
    • JSTL Introduction
    • JSTL Core Tags
    • JSTL out tag
    • JSTL ForEach Tag
    • JSTL Set Tag
    • JSTL If Tag
    • JSTL Catch Tag
    • JSTL If Else Statement
    • JSTL Choose Tag
    • JSTL Remove Tag
    • JSTL Import Tag
    • JSTL ForTokens Tag
    • JSTL Param Tag
    • JSTL url Tag
    • JSTL Redirect Tag
    • JSTL Functions Tags
    • JSTL Length Function
    • JSTL substringBefore
    • JSTL Substring Function
    • JSTL Trim Function
    • JSTL Replace Function
    • JSTL Contains Function
    • JSTL Join Function
    • JSTL IndexOf Function
    • JSTL split Function
    • JSTL StartsWith
    • JSTL endsWith Function
    • JSTL toLowerCase Function
    • JSTL formatNumber Tag
    • JSTL minFractionDigits
    • JSTL toUpperCase Function
    • JSTL containsIgnoreCase
    • JSTL Formatting Tags
    • JSTL maxFractionDigits
    • JSTL minIntegerDigits
    • JSTL maxIntegerDigits
    • JSTL Format Currency
    • JSTL SQL dateParam Tag
    • JSTL SQL Transaction Tag
    • JSTL SQL Tags
    • JSTL SQL Transaction Isolation Attribute
    • JSTL groupingUsed
    • JSTL SQL SetDataSource
    • JSTL Format Percent
    • JSTL SQL Query Tag
    • JSTL SQL UPDATE Tag
    • JSTL SQL Param Tag
    • JSTL Message Format
    • JSTL Set Locale
    • JSTL Parse Number
    • JSTL escapeXml Function
    • JSTL substringAfter
  • JSP Exception Handling
    • JspTagException
    • JasperException:
    • PropertyNotFoundException
    • javax.servlet.jsp.JspTagException: Don't know how to iterate

JSTL IF Tag

JSTL c:if tag is used as a conditional statement in JSP. It is similar like If statement in JAVA. Based on condition evaluation within test attribute, if tag decides to run the code within JSTL IF tag. 

JSTL c:if tag Example

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>JSTL if tag Example</title>
  </head>
  <body>
     <c:if test="${weight > 0}"/>
         <c:out value="${weight}"/>
     </c:if>
  </body>
</html>

As you can see above, in the JSTL c:if tag, test attribute check the condition and if condition returns true, it executes the other statements within <c:if> and </c:if> statement.

JSTL Set Tag ⇐ PREVIOUS
NEXT ⇒ JSTL If Else Statement Example
Java is a trademark of Oracle.
Apekshit.com is just for learning and testing. To improve basic understanding we provide some examples. We are constantly reviewing it to avoid errors, but we cannot warrant full correctness of all content.