I have a custom tag in a \".tag\" file that computes and outputs a value. Because I cannot post the code here, let\'s assume a simple example.
Content of file mytag.tag:
Ran into this same issue and found a way to this without a "hard-coded" variable name that has to match between .jsp and .tag.
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%><%@
taglib prefix="s" uri="http://www.springframework.org/tags" %>
${pageContext.request.setAttribute(var, someOutput)}
${someOutput}
This tag can be used in two ways:
<%-- Option 1: renders the output of the tag directly to the page --%>
<%-- Option 2: stores the output of the tag in variable called "result" and lets the caller render the output on his own --%>