1

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

Roman C
  • 49,761
  • 33
  • 66
  • 176
Leon Armstrong
  • 1,285
  • 3
  • 16
  • 41
  • 2
    Check the generated HTML code. My guess is that it contains , which means that the if tag is not interpreted, probably because you didn't declare the code library at the top of the JSP. – JB Nizet Dec 25 '14 at 13:12
  • I have checked the html , the c:if is printed in html , what does that mean? – Leon Armstrong Dec 25 '14 at 13:14
  • 1
    It means that the if tag is not interpreted, probably because you didn't declare the code library at the top of the JSP. – JB Nizet Dec 25 '14 at 13:15

1 Answers1

2

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.

Community
  • 1
  • 1
Roman C
  • 49,761
  • 33
  • 66
  • 176