I am truncating a string if it is beyond a certain length. I'm super new to jsp, so I'm doing it the only way I know how. I have a bit of javascript that will create a new var with the truncated string. I need to use this new displayTag string within the html. However, I realized I can't use that var outside of the script tags. How can I achieve this?
<script type="text/javascript">
var displayTag = "${example.name}";
if(displayTag.length > 15) {displayTag=displayTag.substring(0,15)+"..."};
alert(displayTag); // for testing
</script>
<a href="some_link"><c:out value=displayTag/></a> // I know this line will not actually work
${example.name}. Even if it was just${example.name}, the JS is still valid since${example.name}is inside a string.fn:substringalong withfn:lengthwill let you do what you want.