The if statement in a JSP WITH JSTL



Introduction

The JavaServer Pages Standard Tag Library (JSTL) allows you to use functional tags which simplify  programming in JSP’s. This example shows how it’s done with a simple test for a condition

<%-- Declare the core library --%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>

<%-- Simple  conditions --%>
<c: test='${param.p == "someValue"}'>
    Generate this template text  p equals someValue
</c:>

<c: test='${param.p}'>
    Generate this template text  p equals "true"
</c:>

Reference:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.