It is just like a if condition in Java, So, <c:if> tag is used as a conditional statement in or Jsp pages
This tag contains attributes test,var,scope. Here test is a mandatory one and var,scope's are optional
one , we specify the evaluated condition to test attribute ,the type of the test attribute is boolean , If the condition is true then the statements will be executed with in the <c:if> and </c:if> tags. Lets' go for example program
Example :
- <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
- pageEncoding="ISO-8859-1"%>
- <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
- <!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>Insert title here</title>
- </head>
- <body>
- <c:set var="money" scope="session" value="${10000}"/>
- <c:if test="${money> 0}">
- <c:out value="${money}"></c:out>
- </c:if>
- </body>
- </html>
Save the above code with Extension dot JSP(.jsp)

0 comments:
Post a Comment