paula paula - 27 days ago 4x
Java Question

Value of c:when test in jsp is not recognized

this is my code, but always is evaluate clause otherwise

var typeA= entity.type;

"<div class='panel panel-default'>"
+ "<div class='panel-heading'> <h4 class='panel-title text'> <a style='text-decoration: none' class='accordion-toggle collapsed' data-toggle='collapse' data-parent='#accordion' href='#collapse"
+ id
+ "' onclick='selectActivityForProspect("
+ id
+ ")'> "
+"<c:choose> <c:when test='${"+typeA+" eq \'EMAIL\'}'> <img src='${pageContext.request.contextPath}/resources/images/email.png' width='16' height='16'/>"
+ "</c:when> <c:when test='${"+typeA+" == CALL}'> <img src='${pageContext.request.contextPath}/resources/images/call.png' width='16' height='16'/>"
+ " </c:when> <c:otherwise> <img src='${pageContext.request.contextPath}/resources/images/campaign.png' width='16' height='16'/>"
+ " </c:otherwise></c:choose>&nbsp;&nbsp; "

var typeA is not recognized. Any ideas? Thanks!


I think this deserve an answer to put you on the right tracks.

You are not understanding the difference between the server and client part.

JSP is a server code, it is run ONLY on the server. The client (browser) can't understand it. Every tags in jsp will be decoded and replace by the output (the value of c:out/ the value between a specific tag condition/...).

The client part (on the browser) can't understand the jsp but is know javascript. This is why you can use JQuery (written in Javascript).

This is the same for every server langage (PHP, ASP, ...), you write it for the server to be understand by the server. The client will NEVER receive anything in those langage.