How can I access the JSP context inside a custom EL function.
You have to explicitly include it as an argument to the method that implements your EL function.
Java method that implements EL function:
public static Object findAttribute(String name, PageContext context) {
return context.findAttribute(name);
}
TLD entry for EL function:
<function>
<name>findAttribute</name>
<function-class>kschneid.Functions</function-class>
<function-signature>java.lang.Object findAttribute(java.lang.String, javax.servlet.jsp.PageContext)</function-signature>
</function>
Usage in JSP:
<%@ taglib prefix="kfn" uri="http://kschneid.com/jsp/functions" %>
...
<c:if test="${empty kfn:findAttribute('userId', pageContext)}">...</c:if>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With