Leon Armstrong
Leon Armstrong

Reputation: 1303

JSTL if tag always execute as true

I am working with a JSTL and trying to implement a if tag

below is my code for file login.tag

<c:if test="${not empty param.error}">
        //do something
</c:if>

My understanding is when I access this page

with path/index.jsp   //the if tag is not executed 
with path/index.jsp?error=wrongpassword   //the if tag is executed

But what I am getting now is the if tag is always execute true, Please advice

Upvotes: 1

Views: 490

Answers (1)

Roman C
Roman C

Reputation: 1

If you want to use c:if tag you should use JSP taglib directive for JSTL core tag library. Use below code at the top of the JSP

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

You also need libraries for JSTL as dependencies to your project. See this answer to find maven dependencies.

Upvotes: 2

Related Questions