Question

I'm trying to do something like this:

<script type="text/javascript" src="<c:out value="${jsDirectory}javascript/StoreCommonUtilities.<tag:versionnumber/>js"/>"></script>

Where <tag:versionnumber/> is a custom JSP tag that works on its own. Currently, it just literally prints out "<tag:versionnumber/>". Any help is appreciated.

Was it helpful?

Solution

<c:out> is used to escape special HTML characters (<, >, &, ' and "). I sure hope you don't have those characters in the jsDirectory attribute. So there's no reason to use <c:out>:

<script type="text/javascript" src="${jsDirectory}javascript/StoreCommonUtilities.<tag:versionnumber/>js"></script>

That said, if you want to use the value of <tag:versionnumber> in other tag attributes, you should create an EL function instead of a tag, or make it possible to store the result in a page-scope attribute, as <c:set> does:

<tag:versionnumber var="version"/>
<c:out value="${version}"/>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top