I’m trying to write a custom tab with attributes, but I can not get the tag handler class to read the attribute values. Using an <%= %> , I can get objValue to work. But objValue2 does not get evaluated when I use ${}.
jsp:
<% CommitmentItem ci = (CommitmentItem) request.getAttribute("commitmentItem"); %>
<myTag:calPOP objValue="<%= ci.getSource() %>" objValue2="${commitmentItem.source}" > </myTag:calPOP>
Tag Handler:
<getters & setters here>
public int doStartTag() throws JspException {
pc.setAttribute("objValue2", objValue);
System.out.println("Object Value = " + objValue );
System.out.println("Object2 Value = " + objValue2 );
Console output:
Object Value = Contract W23AG-23
Object2 Value = ${commitmentItem.source}
If you are writing in JSP1.2, then EL expressions are not interpreted directly by the container. The JSTL tags themselves handle them.
You might try the solution documented here
Basically it involves using the ExpressionUtil.evalNotNull method (part of JSTL library)
Another thing that might work, but will potentially break other things:
If it is the case of having a version of Tomcat that understands EL but is disabled via the web.xml settings, this will switch EL evaluation on for this page only.
Of course any EL expressions in JSTL tags would subsequently throw exceptions as the JSTL1.0 tags don’t accept runtime expressions.