I am relatively new to working with JSPs and I have a feeling I’m overlooking something simple. I have a segment that appends a key onto a URL before sending the user back to where they came from. The key is a string value and when it consists of only numberic values(for example 12345) it works fine, but when it contains non-numerics(for example abcde) it simply appends “#” to the url and stays on the same page.
<core:when test="${dataTransferObject.someBoolean}">
<a href="#" onclick="javascript:location='path/back/to/their/home.request?cachekey='+<core:out value="${dataTransferObject.stringVariable}"/>;return false;">Back to Home </a>
</core:when>
When it’s a string the JavaScript will be illegal–it will think you’re trying to reference a non-existent JavaScript variable. You will see an error your JavaScript console.
Don’t do any JavaScript operations; JSP is evaluated on the server side before the client sees it:
Better yet, use JSP EL:
Also, if this is the JSTL core tag library, the canonical prefix is
"c".