views:

32

answers:

1

Hello,

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>
A: 

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?

kschneid
Sure. When I execute the .JSP that references the tag, for the forementioned code (called url.tag), I receive the error message below. The url attribute is set/provided to the tag. Error: oracle.jsp.parse.JspParseException: /WEB-INF/tags/url.tag: Line # 9, <c:if test="${!empty url}"> Error: Expression Language not supported in compile time attribute test
Ted
Update to JSTL 1.1 (pay attention to the taglib uris) and make sure your web.xml matches the latest servlet version supported by your container. Which app server (including its version) are you using?
kschneid
Thanks for the suggestion. After updating the JSTL to 1.1.2, the code works.
Ted