Search code examples
javajstljsp-tags

Accessing a JSP tag's attribute in JSTL


How do I access a JSP tag's attribute value within a JSTL tag? In the code below, I would like to access the url attribute and test if it's empty. I am using the JSTL 1.0 specification.

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ attribute name="url" required="false"%>

<c:if test="${!empty url}">
   ...
</c:if>

Solution

  • If you're creating tag files, then you're using at least JSP 2.0 - which means you should be using at least JSTL 1.1. At any rate, the attribute directive should create a page-scoped var with the same name as its name attribute (unless it's optional and not provided). So, can you provide any more detail on the errors and/or output you're observing?